@tristan2828/ui-foundation 4.136.1 → 4.137.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/README.md +7 -6
- package/bin/ui-foundation.mjs +1 -1
- package/conventions/agents/spec-tester.md +3 -3
- package/conventions/docs/add-an-entity.md +722 -714
- package/conventions/docs/cell-patterns.md +206 -378
- package/conventions/docs/column-options.md +6 -12
- package/conventions/docs/design-language.md +293 -515
- package/conventions/docs/entity-plan-template.md +9 -7
- package/conventions/docs/reminders.md +12 -17
- package/conventions/docs/timed-screens.md +17 -20
- package/dist/components/app/action-error.js +1 -1
- package/dist/components/app/action-hint.js +1 -1
- package/dist/components/app/app-shell-bottom-bar.js +4 -4
- package/dist/components/app/app-shell-nav.d.ts +1 -1
- package/dist/components/app/app-shell-nav.js +1 -1
- package/dist/components/app/app-shell.d.ts +1 -1
- package/dist/components/app/app-shell.js +9 -9
- package/dist/components/app/board.d.ts +13 -13
- package/dist/components/app/board.js +3 -3
- package/dist/components/app/choice-buttons.d.ts +1 -1
- package/dist/components/app/data-table-tools.d.ts +3 -3
- package/dist/components/app/data-table.d.ts +11 -13
- package/dist/components/app/data-table.js +5 -5
- package/dist/components/app/date-field.js +1 -1
- package/dist/components/app/delete-action.d.ts +1 -1
- package/dist/components/app/delete-action.js +4 -4
- package/dist/components/app/edit-caret.js +1 -1
- package/dist/components/app/edit-in-place-presets.d.ts +4 -4
- package/dist/components/app/edit-in-place-store.d.ts +3 -3
- package/dist/components/app/edit-in-place-store.js +7 -7
- package/dist/components/app/editable-list.js +2 -3
- package/dist/components/app/editable-value.d.ts +2 -2
- package/dist/components/app/editable-value.js +20 -20
- package/dist/components/app/entity-form.js +2 -2
- package/dist/components/app/entity-view-facts.d.ts +12 -12
- package/dist/components/app/entity-view-facts.js +1 -1
- package/dist/components/app/entity-view.d.ts +16 -16
- package/dist/components/app/entity-view.js +28 -33
- package/dist/components/app/equal-items.js +4 -4
- package/dist/components/app/fact-extras.js +5 -5
- package/dist/components/app/field-rows.js +5 -5
- package/dist/components/app/fill-in-queue.js +2 -3
- package/dist/components/app/filter-bar.d.ts +1 -1
- package/dist/components/app/filter-date.js +1 -1
- package/dist/components/app/filter-name.js +1 -1
- package/dist/components/app/form-dialog.js +2 -2
- package/dist/components/app/form-leave-guard.js +2 -2
- package/dist/components/app/form-section.js +1 -1
- package/dist/components/app/icon-action.d.ts +1 -1
- package/dist/components/app/icon-action.js +2 -2
- package/dist/components/app/image-field.js +0 -1
- package/dist/components/app/keep-pencil-room.js +1 -1
- package/dist/components/app/key-stats.d.ts +3 -3
- package/dist/components/app/line-chart.d.ts +1 -1
- package/dist/components/app/line-chart.js +3 -3
- package/dist/components/app/list-editor-rows.js +1 -1
- package/dist/components/app/list-editor.js +1 -1
- package/dist/components/app/list-header.d.ts +6 -6
- package/dist/components/app/list-header.js +8 -8
- package/dist/components/app/markdown.js +30 -37
- package/dist/components/app/milkdown-editor.js +37 -62
- package/dist/components/app/module-card.js +6 -7
- package/dist/components/app/month-calendar.d.ts +46 -0
- package/dist/components/app/month-calendar.js +160 -0
- package/dist/components/app/month-day-field.js +0 -1
- package/dist/components/app/multi-choice.d.ts +1 -1
- package/dist/components/app/multi-choice.js +3 -3
- package/dist/components/app/multi-line-chart.js +1 -1
- package/dist/components/app/multi-pick.js +9 -10
- package/dist/components/app/multi-reference.js +2 -2
- package/dist/components/app/notes-outline.js +0 -1
- package/dist/components/app/notify.js +2 -2
- package/dist/components/app/offline-notice.js +1 -1
- package/dist/components/app/option-icon.js +1 -1
- package/dist/components/app/option-select.d.ts +1 -1
- package/dist/components/app/overview-page.d.ts +2 -2
- package/dist/components/app/overview-page.js +1 -1
- package/dist/components/app/page-trail-context.js +1 -1
- package/dist/components/app/pill-filter.d.ts +2 -2
- package/dist/components/app/prose-look.js +1 -1
- package/dist/components/app/rating-input.js +1 -1
- package/dist/components/app/rating-score.js +1 -1
- package/dist/components/app/record-dialog.js +25 -40
- package/dist/components/app/recurrence-field.js +6 -6
- package/dist/components/app/reference-combobox.js +1 -2
- package/dist/components/app/rich-text-box-anchor.js +0 -1
- package/dist/components/app/rich-text-edges.js +2 -2
- package/dist/components/app/rich-text-editor.d.ts +2 -3
- package/dist/components/app/rich-text-editor.js +19 -32
- package/dist/components/app/rich-text-empty-paragraph.d.ts +6 -7
- package/dist/components/app/rich-text-empty-paragraph.js +6 -7
- package/dist/components/app/rich-text-floating-toolbar.js +0 -1
- package/dist/components/app/rich-text-formats.js +2 -2
- package/dist/components/app/rich-text-input-rules.js +1 -2
- package/dist/components/app/rich-text-keyboard-bar.js +6 -7
- package/dist/components/app/rich-text-node-views.js +1 -2
- package/dist/components/app/rich-text-shortcuts.js +8 -8
- package/dist/components/app/rich-text-slash-menu.js +4 -6
- package/dist/components/app/rich-text-slash.d.ts +2 -2
- package/dist/components/app/rich-text-slash.js +2 -2
- package/dist/components/app/rich-text-table-grips.d.ts +1 -1
- package/dist/components/app/rich-text-table-grips.js +1 -2
- package/dist/components/app/rich-text-tasks.d.ts +1 -1
- package/dist/components/app/rich-text-tasks.js +1 -1
- package/dist/components/app/rich-text-touch.js +1 -1
- package/dist/components/app/search-palette.js +1 -2
- package/dist/components/app/secondary-filters.js +2 -3
- package/dist/components/app/session-view.js +1 -1
- package/dist/components/app/stacked-area-chart.js +1 -1
- package/dist/components/app/step-track.d.ts +1 -1
- package/dist/components/app/step-track.js +3 -3
- package/dist/components/app/widget-card.js +26 -30
- package/dist/components/app/widget-layout-sheet.js +1 -1
- package/dist/components/ui/calendar.js +2 -2
- package/dist/components/ui/combobox.d.ts +1 -1
- package/dist/components/ui/combobox.js +2 -2
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +6 -6
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/sonner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/error-reporting/reporter.d.ts +1 -1
- package/dist/error-reporting/reporter.js +1 -1
- package/dist/hooks/table-url-changes.d.ts +2 -2
- package/dist/hooks/table-url-changes.js +5 -6
- package/dist/hooks/use-action.js +1 -1
- package/dist/hooks/use-record-update.js +1 -1
- package/dist/hooks/use-table-url-state.d.ts +1 -1
- package/dist/hooks/use-table-url-state.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/lib/audio-cues.js +2 -2
- package/dist/lib/connection.js +1 -1
- package/dist/lib/date-filter.js +1 -1
- package/dist/lib/entity-view-tab.js +1 -1
- package/dist/lib/field-rows.js +2 -2
- package/dist/lib/form-errors.d.ts +1 -1
- package/dist/lib/form-errors.js +1 -1
- package/dist/lib/keep-audio-alive.js +1 -1
- package/dist/lib/line-chart-layout.js +3 -3
- package/dist/lib/markdown-inline.js +0 -2
- package/dist/lib/markdown-merge.js +2 -2
- package/dist/lib/markdown-table-widths.js +1 -1
- package/dist/lib/markdown-table.js +1 -2
- package/dist/lib/markdown-toggle.js +1 -1
- package/dist/lib/page-leaving.js +1 -1
- package/dist/lib/recurrence-format.d.ts +2 -2
- package/dist/lib/recurrence-format.js +1 -1
- package/dist/lib/recurrence-phrase.d.ts +1 -1
- package/dist/lib/recurrence-phrase.js +2 -2
- package/dist/lib/recurrence.d.ts +1 -1
- package/dist/lib/recurrence.js +2 -2
- package/dist/lib/stale-chunk-reload.js +1 -1
- package/dist/lib/status-kinds.d.ts +1 -1
- package/dist/lib/status-kinds.js +2 -2
- package/dist/mocks/start-worker.js +2 -2
- package/dist/routes/login.js +1 -1
- package/dist/testing/index.d.ts +7 -4
- package/dist/testing/index.js +10 -13
- package/package.json +1 -1
- package/styles/index.css +3 -3
- package/styles/theme.css +14 -20
- package/vite/pwa.js +1 -1
|
@@ -16,8 +16,8 @@ export type PillFilterProps = {
|
|
|
16
16
|
};
|
|
17
17
|
export declare function PillFilter({ label, options, value, onValueChange, allLabel, className }: PillFilterProps): import("react").JSX.Element;
|
|
18
18
|
/**
|
|
19
|
-
* One pill as PillGroup draws it: a PillFilterOption, and for DataTable's
|
|
20
|
-
* views
|
|
19
|
+
* One pill as PillGroup draws it: a PillFilterOption, and, for DataTable's
|
|
20
|
+
* views, a count after the label, "Needs a Look · 3".
|
|
21
21
|
*/
|
|
22
22
|
export type PillGroupOption = PillFilterOption & {
|
|
23
23
|
/** The number shown after the label; null, undefined or 0 shows none, past 99 "99+". */
|
|
@@ -38,7 +38,7 @@ export const PROSE = {
|
|
|
38
38
|
* down while the section shows and right while it's folded.
|
|
39
39
|
*/
|
|
40
40
|
export const FOLD_BUTTON = '-ml-1 flex h-[1lh] w-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50' +
|
|
41
|
-
// On a touch screen, an invisible 40px square round it takes the tap
|
|
41
|
+
// On a touch screen, an invisible 40px square round it takes the tap.
|
|
42
42
|
" relative pointer-coarse:before:absolute pointer-coarse:before:top-1/2 pointer-coarse:before:left-1/2 pointer-coarse:before:size-10 pointer-coarse:before:-translate-1/2 pointer-coarse:before:content-['']";
|
|
43
43
|
/** A heading with a fold button: the button and the words side by side, the look on both. */
|
|
44
44
|
export const FOLD_HEADING = 'flex items-start gap-1';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// A score out of a few, set by clicking a star (cell pattern 9
|
|
2
|
+
// A score out of a few, set by clicking a star (cell pattern 9):
|
|
3
3
|
// RatingScore's glyphs and tokens, as a control. "My Rating" as ★★★★☆,
|
|
4
4
|
// where a click on the second star makes it 2.
|
|
5
5
|
//
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// A score out of a few (cell pattern 9
|
|
2
|
+
// A score out of a few (cell pattern 9): `max` stars or hearts,
|
|
3
3
|
// the first `value` filled. "My Rating: 4 of 5" as ★★★★☆. The count of
|
|
4
4
|
// filled glyphs carries the value, so it survives greyscale.
|
|
5
5
|
//
|
|
@@ -28,47 +28,32 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
28
28
|
// another page opens the dialog over its own list, at the list's plain
|
|
29
29
|
// address.
|
|
30
30
|
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// has no element) and
|
|
31
|
+
// Variants, all the same route shape:
|
|
32
|
+
// - `listPath`: a list that isn't the record's parent route (the list at
|
|
33
|
+
// /things/list, the record at /things/12). The shared route wraps both,
|
|
34
|
+
// its `list` drawn at `listPath` (whose own route has no element) and
|
|
35
|
+
// every other child the record:
|
|
36
|
+
// `{ path: 'things', element: <RecordDialogRoute list={<ThingsList />} listPath="list" label="Thing" />, children: [{ path: 'list' }, { path: ':id', element: <ThingView /> }] }`
|
|
37
|
+
// - A sub-record over its parent's page: the parent's page is the `list`,
|
|
38
|
+
// the sub-record its child, with `fullPage={false}`, so a reload of
|
|
39
|
+
// /parents/7/children/31 is the dialog over the parent again.
|
|
40
|
+
// - `newPath`: the list's `new` child route (`/widgets/new`) is the create
|
|
41
|
+
// form, drawn as its own FormDialog over the list, always (a form of up
|
|
42
|
+
// to about 8 fields has no page of its own). It has no record dialog
|
|
43
|
+
// round it; FormDialog opens itself from the route's context
|
|
44
|
+
// (useNewRecordDialog), closing goes back as a record's dialog does, and
|
|
45
|
+
// `openRecord` after the save swaps the entry for the new record over
|
|
46
|
+
// the same list.
|
|
35
47
|
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
48
|
+
// The record dialog is 1,120px (DialogContent `size="record"`), so an
|
|
49
|
+
// EntityView with `layout="rail"` keeps its rail beside the main column, as
|
|
50
|
+
// on its page; a narrower screen stacks them.
|
|
38
51
|
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
// `fullPage={false}`, so a reload of /parents/7/children/31 is the dialog
|
|
45
|
-
// over the parent again:
|
|
46
|
-
//
|
|
47
|
-
// { path: 'parents/:id', element: <RecordDialogRoute list={<ParentView />} label="Document" fullPage={false} />,
|
|
48
|
-
// children: [{ path: 'children/:childId', element: <ChildView /> }] }
|
|
49
|
-
//
|
|
50
|
-
// A new record over its list (4.82, `newPath`): the list's `new` child
|
|
51
|
-
// route (`/widgets/new`) is the create form, drawn as its own FormDialog
|
|
52
|
-
// over the list, always: opened from the list, from anywhere else, or a
|
|
53
|
-
// deep link (a form of up to about 8 fields has no page of its own). It
|
|
54
|
-
// has no record dialog round it; FormDialog opens itself from the
|
|
55
|
-
// route's context (useNewRecordDialog), closing goes back as a record's
|
|
56
|
-
// dialog does, and `openRecord` after the save swaps the entry for the new
|
|
57
|
-
// record over the same list:
|
|
58
|
-
//
|
|
59
|
-
// { path: 'widgets', element: <RecordDialogRoute list={<WidgetsTableRoute />} label="Widget" newPath="new" />,
|
|
60
|
-
// children: [{ path: 'new', element: <NewWidgetRoute /> }, { path: ':id', element: <WidgetViewRoute /> }] }
|
|
61
|
-
//
|
|
62
|
-
// The record dialog is 1,120px (DialogContent `size="record"`, 4.82), so
|
|
63
|
-
// an EntityView with `layout="rail"` keeps its rail beside the main
|
|
64
|
-
// column, as on its page; a narrower screen stacks them.
|
|
65
|
-
//
|
|
66
|
-
// A tiny record (4.98, record standard 8A: a few fields and no notes)
|
|
67
|
-
// opens as a small card instead, `look="card"`: a 420px dialog (a bottom
|
|
68
|
-
// sheet on a phone, DialogContent `size="confirm"`) with no bar. The
|
|
69
|
-
// record's title, its actions (Delete as an icon), Open full page (an
|
|
70
|
-
// icon, when it has a page) and Close share one line, and its facts are
|
|
71
|
-
// plain rows under it, with no cards.
|
|
52
|
+
// A tiny record (record standard 8A: a few fields and no notes) opens as a
|
|
53
|
+
// small card instead, `look="card"`: a 420px dialog (a bottom sheet on a
|
|
54
|
+
// phone, DialogContent `size="confirm"`) with no bar. The record's title,
|
|
55
|
+
// its actions (Delete as an icon), Open full page (an icon, when it has a
|
|
56
|
+
// page) and Close share one line, and its facts are plain rows under it.
|
|
72
57
|
//
|
|
73
58
|
// Inside, the record's route renders as it always does. EntityView sees
|
|
74
59
|
// the dialog (useRecordDialog): its heading names the dialog, its back link
|
|
@@ -163,7 +148,7 @@ export function RecordDialogRoute({ list, label, className, look = 'record', ful
|
|
|
163
148
|
close();
|
|
164
149
|
}, children: _jsxs(DialogContent, { showCloseButton: false, "aria-labelledby": titleId, "aria-label": label, "data-slot": "record-dialog", size: card ? 'confirm' : 'record', "data-look": look, className: cn('gap-0 overflow-hidden p-0 data-closed:hidden', card && 'flex max-h-[calc(100dvh-2rem)] flex-col', className), children: [!card && (_jsxs("div", { className: cn('flex items-center gap-2 border-b px-2 py-2', fullPage ? 'justify-between' : 'justify-end'), children: [fullPage && (_jsxs(Link, { to: { pathname: location.pathname, search: location.search, hash: location.hash }, replace: true, className: buttonVariants({ variant: 'ghost', size: 'sm' }), children: [_jsx(Maximize2Icon, { "aria-hidden": "true" }), "Open Full Page"] })), _jsxs(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon-sm" }), children: [_jsx(XIcon, { "aria-hidden": "true" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })), _jsx("div", { "data-slot": "record-dialog-body", className: cn('min-h-0 overflow-y-auto',
|
|
165
150
|
// A record's tab bar sticks to the body's top edge, not inside
|
|
166
|
-
// its padding
|
|
151
|
+
// its padding: minus the padding, for EntityView.
|
|
167
152
|
card
|
|
168
153
|
? 'p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] [--entity-view-sticky-top:-1rem] md:p-5 md:[--entity-view-sticky-top:-1.25rem]'
|
|
169
154
|
: 'p-4 [--entity-view-sticky-top:-1rem] sm:p-6 sm:[--entity-view-sticky-top:-1.5rem]'), children: _jsx(RecordDialogContext.Provider, { value: dialog, children: open && outlet }) })] }) })] }));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
// How something repeats
|
|
2
|
+
// How something repeats: a reminder's or a task's schedule. The
|
|
3
3
|
// value is the contract's `Recurrence` (`lib/recurrence.ts`), or `null`
|
|
4
4
|
// for none.
|
|
5
5
|
//
|
|
6
6
|
// Three parts, one under the other:
|
|
7
|
-
// - **Presets**, a row of toggle buttons: Daily, Weekdays, Weekly
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// - **Presets**, a row of toggle buttons: Daily, Weekdays, Weekly, Monthly
|
|
8
|
+
// (on the day or the nth weekday), Yearly (each from the start day) and
|
|
9
|
+
// Custom. The one the value is stays pressed; Custom is pressed for
|
|
10
|
+
// anything else, and moves to the phrase box.
|
|
11
11
|
// - **The phrase box**, read as you type (`parseRecurrencePhrase`): "every
|
|
12
12
|
// 2nd tue at 9am", "every! 3 days", "every jan 1 until mar 1". What it
|
|
13
13
|
// can't read is said under it, and the field gives `null`, so a form
|
|
@@ -15,7 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
15
15
|
// - **The preview**: the rule's label ("Every 2nd Tue at 9:00 AM") and its
|
|
16
16
|
// next five occurrences, in the rule's zone, or why it can't be read.
|
|
17
17
|
//
|
|
18
|
-
// Two options an app's own records may want
|
|
18
|
+
// Two options an app's own records may want:
|
|
19
19
|
// - `times={false}`, for a record whose times are fields of its own (a
|
|
20
20
|
// calendar's events): the preview lists dates only ("Tue, Dec 8", from
|
|
21
21
|
// today on), the label and the box say no times, and typing "at 9am" is
|
|
@@ -7,7 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
// `label`, so a pick the current search no longer returns still shows its
|
|
8
8
|
// name.
|
|
9
9
|
//
|
|
10
|
-
// `onCreate` (
|
|
10
|
+
// `onCreate` (the form standard): when what's typed matches no
|
|
11
11
|
// record's name, Create "<typed>" is the list's last item. Picking it
|
|
12
12
|
// calls the app's `onCreate(name)`, which opens its small create form (a
|
|
13
13
|
// FormDialog) with the name filled in and resolves with the new record
|
|
@@ -20,7 +20,6 @@ import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem,
|
|
|
20
20
|
const NONE = '__none__';
|
|
21
21
|
/** The Create "<typed>" item. */
|
|
22
22
|
const CREATE = '__create__';
|
|
23
|
-
// How long typing pauses before the search runs.
|
|
24
23
|
const SEARCH_DELAY_MS = 200;
|
|
25
24
|
export function ReferenceCombobox({ id, value, onValueChange, search, label, required = false, emptyLabel = 'Not set', placeholder = 'Search', emptyText = 'No matches.', onCreate, readOnly = false, defaultOpen = false, invalid = false, ...aria }) {
|
|
26
25
|
const [text, setText] = useState('');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The note's two edges
|
|
1
|
+
// The note's two edges: a code
|
|
2
2
|
// block, a table, a quote, a callout or a divider that ends a note had no
|
|
3
3
|
// way past it (Ctrl+Enter, shown nowhere, and none on a phone), and one
|
|
4
4
|
// that starts it nothing above it.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// a short note) puts the caret on a line under it: a new one, unless the
|
|
11
11
|
// last block is already a paragraph. A click above the first block, a
|
|
12
12
|
// line above it when that block isn't one.
|
|
13
|
-
// - Ticking a task's box keeps focus in the text
|
|
13
|
+
// - Ticking a task's box keeps focus in the text, so
|
|
14
14
|
// Ctrl+Z takes the tick back: from outside, the caret lands in that item.
|
|
15
15
|
// No trailing-paragraph rule: a note isn't given a line nobody typed, so
|
|
16
16
|
// nothing is saved until one is asked for. And no gap cursor, which can't
|
|
@@ -60,9 +60,8 @@ export type RichTextEditorProps = {
|
|
|
60
60
|
* Images uploaded into the text: pasted, dropped, or picked with an
|
|
61
61
|
* Image button (on the fixed toolbar; with `toolbar="floating"`, on the
|
|
62
62
|
* "Editor tools" strip shown while the field has focus; on a phone, in
|
|
63
|
-
* the row pinned to the keyboard) or the slash menu's Image ("/image"
|
|
64
|
-
*
|
|
65
|
-
* app's own storage: the package knows no endpoint) and goes in as
|
|
63
|
+
* the row pinned to the keyboard) or the slash menu's Image ("/image"). Each file goes
|
|
64
|
+
* through this (the app's own storage: the package knows no endpoint) and goes in as
|
|
66
65
|
* ``, from the result's `url`, else its `thumbUrl`. A
|
|
67
66
|
* placeholder shows where it will go while it uploads (it isn't saved);
|
|
68
67
|
* a refused file or a failed upload takes it away and says why in a
|
|
@@ -11,42 +11,29 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
11
11
|
// stays on screen, nothing is saved in its place), the editor marks itself
|
|
12
12
|
// invalid, and `onProblem` says why; with no `onProblem`, the editor says
|
|
13
13
|
// it itself, inside the field. A form gives `onProblem` and holds its
|
|
14
|
-
// submit on it (add-an-entity.md "
|
|
14
|
+
// submit on it (add-an-entity.md "Forms"), or Save would send the last
|
|
15
15
|
// text that could be saved and say it worked.
|
|
16
16
|
//
|
|
17
17
|
// Raw HTML in the text shows as its characters, as <Markdown> shows it,
|
|
18
18
|
// and nothing pasted or typed can add markup.
|
|
19
19
|
//
|
|
20
|
-
// Headings
|
|
21
|
-
// <
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// Images in the text (``) show, at most the field's width.
|
|
26
|
-
// With `upload`, an image pasted, dropped or picked with an Image button
|
|
27
|
-
// (the fixed toolbar's, or the tools strip's with `toolbar="floating"`) is
|
|
28
|
-
// uploaded through the app's own storage and goes in as
|
|
29
|
-
// ``; while it uploads, a placeholder shows where it will go.
|
|
30
|
-
//
|
|
31
|
-
// A table's columns fit their words. Grips on its column and row (or a
|
|
32
|
-
// right-click, or Shift+F10, in a cell) open menus to insert, move,
|
|
33
|
-
// delete, align, sort and colour; a header column and cell colours are
|
|
34
|
-
// kept as Markdown already writes them (src/lib/markdown-table.ts).
|
|
35
|
-
// `tableLook` picks compact (the default) or boxed, as on <Markdown>.
|
|
36
|
-
//
|
|
37
|
-
// With `foldKey`, the text folds by its toggle headings (NotesOutline
|
|
38
|
-
// lists every heading beside it), the Markdown untouched. A toggle heading
|
|
20
|
+
// Headings, tables, page links, `foldKey` and `tableLook` follow
|
|
21
|
+
// <Markdown>'s (`headingLevel`, from <h3> by default; a table wider than
|
|
22
|
+
// the field scrolls in a tab stop the arrow keys scroll). Grips on a
|
|
23
|
+
// table's column and row (or a right-click, or Shift+F10, in a cell) open
|
|
24
|
+
// menus to insert, move, delete, align, sort and colour. A toggle heading
|
|
39
25
|
// is `## Safety {toggle="true"}` in the Markdown: typed as `>## `, picked
|
|
40
|
-
// from the slash menu
|
|
41
|
-
//
|
|
26
|
+
// from the slash menu or made with the toolbar's Toggle heading.
|
|
27
|
+
//
|
|
28
|
+
// Images in the text (``) show, at most the field's width. With
|
|
29
|
+
// `upload`, an image pasted, dropped or picked with an Image button is
|
|
30
|
+
// uploaded through the app's own storage and goes in as ``; while
|
|
31
|
+
// it uploads, a placeholder shows where it will go.
|
|
42
32
|
//
|
|
43
|
-
// With `
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
// selected words) asks for a title, has the app make the page, and puts
|
|
48
|
-
// in `[title](href)`. Pages may nest to any depth: a page's own note takes
|
|
49
|
-
// the same props. The Markdown stays plain links.
|
|
33
|
+
// With `onCreatePage`, "/page" (or Turn into page on selected words) asks
|
|
34
|
+
// for a title, has the app make the page, and puts in `[title](href)`.
|
|
35
|
+
// Pages may nest to any depth: a page's own note takes the same props.
|
|
36
|
+
// The Markdown stays plain links.
|
|
50
37
|
//
|
|
51
38
|
// `defaultValue` is read when it mounts, then followed: a new value the
|
|
52
39
|
// editor didn't report itself (a form's loaded record arriving after the
|
|
@@ -56,8 +43,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
56
43
|
//
|
|
57
44
|
// The editor (Milkdown) is loaded on first use, so a page that only reads
|
|
58
45
|
// Markdown never downloads it. Until it arrives the text shows as
|
|
59
|
-
// <Markdown> draws it
|
|
60
|
-
//
|
|
46
|
+
// <Markdown> draws it, the field's size, so nothing moves when the editor
|
|
47
|
+
// takes its place; an empty one shows skeleton lines.
|
|
61
48
|
import { lazy, Suspense, useLayoutEffect, useRef, useState } from 'react';
|
|
62
49
|
import { cn } from 'cn';
|
|
63
50
|
import { Skeleton } from '../ui/skeleton.js';
|
|
@@ -83,7 +70,7 @@ function useOpenings(defaultValue) {
|
|
|
83
70
|
export function RichTextEditor(props) {
|
|
84
71
|
const { opening, report } = useOpenings(props.defaultValue);
|
|
85
72
|
const { onChange } = props;
|
|
86
|
-
// The editor reports what was typed as it unmounts
|
|
73
|
+
// The editor reports what was typed as it unmounts; one replaced
|
|
87
74
|
// by a new value (a reset) has nothing left to say.
|
|
88
75
|
const live = useRef(opening);
|
|
89
76
|
useLayoutEffect(() => {
|
|
@@ -6,13 +6,12 @@ import type { NodeSchema } from '@milkdown/kit/transformer';
|
|
|
6
6
|
* and closes the node with nothing in it, and its serializer then leaves
|
|
7
7
|
* `children` out. mdast says a paragraph always has the array, and
|
|
8
8
|
* mdast-util-gfm-task-list-item 2.0.1 reads its length: an empty task item
|
|
9
|
-
* ("- [ ] ", Enter at a list's end)
|
|
10
|
-
* saved.
|
|
9
|
+
* ("- [ ] ", Enter at a list's end) would throw there and the edit would
|
|
10
|
+
* never be saved.
|
|
11
11
|
*
|
|
12
|
-
* And a paragraph's spaces at its end are left out
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* a node of its own.
|
|
12
|
+
* And a paragraph's spaces at its end are left out: Markdown drops them on
|
|
13
|
+
* reading, so a pause after a space would save a note that reads back
|
|
14
|
+
* without it, and remark-stringify sometimes writes it as ` `. A hard
|
|
15
|
+
* break's spaces aren't these: it is a node of its own.
|
|
17
16
|
*/
|
|
18
17
|
export declare function withEmptyParagraphChildren<Ctx>(previous: (ctx: Ctx) => NodeSchema): (ctx: Ctx) => NodeSchema;
|
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
* and closes the node with nothing in it, and its serializer then leaves
|
|
6
6
|
* `children` out. mdast says a paragraph always has the array, and
|
|
7
7
|
* mdast-util-gfm-task-list-item 2.0.1 reads its length: an empty task item
|
|
8
|
-
* ("- [ ] ", Enter at a list's end)
|
|
9
|
-
* saved.
|
|
8
|
+
* ("- [ ] ", Enter at a list's end) would throw there and the edit would
|
|
9
|
+
* never be saved.
|
|
10
10
|
*
|
|
11
|
-
* And a paragraph's spaces at its end are left out
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* a node of its own.
|
|
11
|
+
* And a paragraph's spaces at its end are left out: Markdown drops them on
|
|
12
|
+
* reading, so a pause after a space would save a note that reads back
|
|
13
|
+
* without it, and remark-stringify sometimes writes it as ` `. A hard
|
|
14
|
+
* break's spaces aren't these: it is a node of its own.
|
|
16
15
|
*/
|
|
17
16
|
export function withEmptyParagraphChildren(previous) {
|
|
18
17
|
return (ctx) => {
|
|
@@ -24,7 +24,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
import { useLayoutEffect, useState } from 'react';
|
|
25
25
|
import { cn } from 'cn';
|
|
26
26
|
import { FormatButtons } from './rich-text-toolbar.js';
|
|
27
|
-
// Its gap from the words.
|
|
28
27
|
const GAP = 8;
|
|
29
28
|
// The selection's box on screen: the words themselves on one line, the
|
|
30
29
|
// text's width over several.
|
|
@@ -253,7 +253,7 @@ export function toggleFormat(state, dispatch, id) {
|
|
|
253
253
|
return true;
|
|
254
254
|
};
|
|
255
255
|
// A heading or a code block is made a plain line first: a list
|
|
256
|
-
// item starts with one (Ctrl+Shift+5 on a heading
|
|
256
|
+
// item starts with one (Ctrl+Shift+5 on a heading).
|
|
257
257
|
const parent = state.selection.$from.parent;
|
|
258
258
|
if (parent.type !== paragraph && parent.isTextblock)
|
|
259
259
|
return chain(state, dispatch, [setBlockType(paragraph), toList]);
|
|
@@ -285,7 +285,7 @@ function chain(state, dispatch, commands) {
|
|
|
285
285
|
}
|
|
286
286
|
// `command` on the caret's line once it's out of every list it's in: a
|
|
287
287
|
// list item's line can't be a heading or a code block (Ctrl+Shift+1 on an
|
|
288
|
-
// item
|
|
288
|
+
// item).
|
|
289
289
|
function outOfLists(state, dispatch, command) {
|
|
290
290
|
if (!ancestor(state, isList))
|
|
291
291
|
return command(state, dispatch);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// The rich-text editor's typed Markdown: Milkdown's input rules, three of
|
|
2
|
-
// them swapped for the editor's own
|
|
3
|
-
// F15, F16 and F22).
|
|
2
|
+
// them swapped for the editor's own:
|
|
4
3
|
// - `---` (or `***`, `___` and a space) on an empty line puts in a divider
|
|
5
4
|
// the way the Divider button does: a line under it, the caret there.
|
|
6
5
|
// Milkdown's left the rule selected, and the next key replaced it.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// The rich-text editor's toolbar on a touch screen
|
|
3
|
-
//
|
|
4
|
-
// keyboard, in place of the rows above the text, which scroll away and
|
|
2
|
+
// The rich-text editor's toolbar on a touch screen: a short row pinned to the top of the
|
|
3
|
+
// phone's keyboard, in place of the rows above the text, which scroll away and
|
|
5
4
|
// take a third of what's left of the note while the keyboard is open.
|
|
6
5
|
//
|
|
7
6
|
// - Shown while the field has focus (or is full screen), on a coarse
|
|
@@ -19,7 +18,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
19
18
|
// the keyboard button in its place brings the keyboard back. Focus stays
|
|
20
19
|
// in the text the whole time (`inputmode="none"` hides the keyboard), so
|
|
21
20
|
// the selection and the caret are kept.
|
|
22
|
-
// - Its buttons are 40px
|
|
21
|
+
// - Its buttons are 40px, on semantic tokens only.
|
|
23
22
|
//
|
|
24
23
|
// Placed inside the field's element, not in a portal, like the floating
|
|
25
24
|
// toolbar (rich-text-floating-toolbar.tsx says why): `position: fixed`,
|
|
@@ -139,8 +138,8 @@ export function RichTextKeyboardBar({ view, state, readOnly, controls, onFormat,
|
|
|
139
138
|
}, [panel, view]);
|
|
140
139
|
// The caret stays in sight above the bar (and the panel): the browser
|
|
141
140
|
// keeps it above the keyboard only. Checked on each edit and caret move
|
|
142
|
-
// in the text itself, as `state` only follows what the bar draws (
|
|
143
|
-
//
|
|
141
|
+
// in the text itself, as `state` only follows what the bar draws (typing
|
|
142
|
+
// doesn't re-render it).
|
|
144
143
|
useLayoutEffect(() => {
|
|
145
144
|
if (!edge || !ready)
|
|
146
145
|
return;
|
|
@@ -196,7 +195,7 @@ export function RichTextKeyboardBar({ view, state, readOnly, controls, onFormat,
|
|
|
196
195
|
virtualKeyboard()?.show();
|
|
197
196
|
view.focus();
|
|
198
197
|
}, children: panel ? _jsx(KeyboardIcon, { "aria-hidden": "true" }) : 'Aa' }), _jsx(Separator, { orientation: "vertical", className: "mx-1 h-6 data-vertical:self-center" }), _jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto [scrollbar-width:none]", children: [_jsx(FormatButtons, { formats: words ? 'keyboardWords' : 'keyboard', state: state, readOnly: readOnly, onFormat: onFormat, text: text, touch: true }), !words && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", size: "icon-lg", "aria-label": "Insert Block", disabled: readOnly || inCode, className: "[&_svg]:size-5", onMouseDown: keep, onClick: () => insertBlock(view), children: _jsx(PlusIcon, { "aria-hidden": "true" }) }), onImage && (_jsx(Button, { variant: "ghost", size: "icon-lg", "aria-label": "Image", disabled: readOnly, className: "[&_svg]:size-5", onMouseDown: keep, onClick: onImage, children: _jsx(ImageIcon, { "aria-hidden": "true" }) })), _jsx(Button, { variant: "ghost", size: "icon-lg", "aria-label": "Undo",
|
|
199
|
-
// Always on: `state` doesn't follow typing
|
|
198
|
+
// Always on: `state` doesn't follow typing, and with nothing
|
|
200
199
|
// to undo it does nothing.
|
|
201
200
|
disabled: readOnly, className: "[&_svg]:size-5", onMouseDown: keep, onClick: press(() => undo(view.state, view.dispatch)), children: _jsx(Undo2Icon, { "aria-hidden": "true" }) })] }))] }), _jsx(Button, { variant: "ghost", size: "icon-lg", "aria-label": "Hide Keyboard", className: "[&_svg]:size-5", onMouseDown: keep, onClick: () => {
|
|
202
201
|
setPanel(false);
|
|
@@ -59,7 +59,6 @@ function columnsOf(node) {
|
|
|
59
59
|
header.forEach((cell) => columns.push(cell.textContent));
|
|
60
60
|
return columns;
|
|
61
61
|
}
|
|
62
|
-
// How far an arrow key scrolls the table's box.
|
|
63
62
|
const SCROLL_STEP = 40;
|
|
64
63
|
// The keys a focused table box takes: the arrow keys, Home and End scroll
|
|
65
64
|
// it, as a box that isn't editable scrolls by itself, and any other plain
|
|
@@ -98,7 +97,7 @@ export function tableView(node, view, getPos, registry) {
|
|
|
98
97
|
const dom = document.createElement('div');
|
|
99
98
|
dom.dataset.slot = 'rich-text-table';
|
|
100
99
|
// As wide as the table (its columns fit their words), never wider than the text.
|
|
101
|
-
// On a touch screen, room above for the column grip's tap area
|
|
100
|
+
// On a touch screen, room above for the column grip's tap area.
|
|
102
101
|
dom.className = 'group/table relative grid w-fit max-w-full grid-cols-[minmax(0,auto)_auto] gap-1 pointer-coarse:pt-3';
|
|
103
102
|
const scroll = document.createElement('div');
|
|
104
103
|
// Its look: styles/index.css "Tables in written text".
|
|
@@ -4,27 +4,27 @@
|
|
|
4
4
|
// 4 tasks, 5 bullets, 6 numbers, 8 a code block), and Cmd+Option and the
|
|
5
5
|
// digit does on a Mac, as in Notion (Cmd+Shift+3 to 5 are the Mac's
|
|
6
6
|
// screenshots). Mod+Shift+S strikes through, also Notion's, and
|
|
7
|
-
// Mod+Shift+H highlights
|
|
7
|
+
// Mod+Shift+H highlights, Notion's too. Each runs the same command
|
|
8
8
|
// as its toolbar button, so it toggles the same way.
|
|
9
9
|
//
|
|
10
10
|
// Read by the key's position (`event.code`), not the character it types:
|
|
11
11
|
// Shift+5 types "%", and Option+5 "∞".
|
|
12
12
|
//
|
|
13
|
-
// And the editing keys Notion, Docs and Obsidian share (
|
|
14
|
-
//
|
|
13
|
+
// And the editing keys Notion, Docs and Obsidian share (each is
|
|
14
|
+
// taken here, before Milkdown's own keymap):
|
|
15
15
|
// - Backspace at the start of a list item's first line lifts the item out
|
|
16
16
|
// of its list (a nested one up a level), its words kept as a line; a
|
|
17
17
|
// second Backspace joins it to the line above. Milkdown's (joinBackward)
|
|
18
|
-
//
|
|
18
|
+
// would fuse a nested item into the item above as its second paragraph.
|
|
19
19
|
// - Tab and Shift+Tab in a list item indent and outdent it, and stay in
|
|
20
20
|
// the text where it can't move (a first item): Tab leaving the editor
|
|
21
|
-
// from one item and not the next
|
|
21
|
+
// from one item and not the next would be a surprise. In a code block they
|
|
22
22
|
// indent and outdent its lines by two spaces. On a plain line Tab still
|
|
23
23
|
// leaves the editor, the keyboard's way on to the rest of the page.
|
|
24
24
|
// - Undo and redo (Mod+Z; Mod+Shift+Z, and Ctrl+Y off Apple) are taken
|
|
25
|
-
// here whether or not there is a step to take
|
|
26
|
-
//
|
|
27
|
-
//
|
|
25
|
+
// here whether or not there is a step to take: ProseMirror's keymap,
|
|
26
|
+
// finding nothing to redo, would run Shift+Mod+Z's unshifted key, Mod+Z,
|
|
27
|
+
// so a redo pressed once too often would undo a step.
|
|
28
28
|
import { redo, undo } from '@milkdown/kit/prose/history';
|
|
29
29
|
import { liftListItem, sinkListItem } from '@milkdown/kit/prose/schema-list';
|
|
30
30
|
import { DEFAULT_HIGHLIGHT } from '../../lib/markdown-highlight.js';
|
|
@@ -10,13 +10,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
// Placed against the field's element like the floating toolbar, not in a
|
|
11
11
|
// portal (rich-text-floating-toolbar.tsx says why): under the caret, or
|
|
12
12
|
// over it when there's more room there, and never taller than what is
|
|
13
|
-
// visible on its side (above a phone's keyboard
|
|
13
|
+
// visible on its side (above a phone's keyboard). Visible
|
|
14
14
|
// means inside whatever clips the field too: a card's `overflow-hidden`
|
|
15
|
-
// cut a menu opened on a note's last line down to its first item.
|
|
15
|
+
// would cut a menu opened on a note's last line down to its first item.
|
|
16
16
|
import { useLayoutEffect, useState } from 'react';
|
|
17
17
|
import { cn } from 'cn';
|
|
18
18
|
import { slashOptionId } from './rich-text-slash.js';
|
|
19
|
-
// Its gap from the caret's line.
|
|
20
19
|
const GAP = 4;
|
|
21
20
|
// Its tallest: every block shows on a laptop.
|
|
22
21
|
const TALLEST = 512;
|
|
@@ -24,7 +23,7 @@ const TALLEST = 512;
|
|
|
24
23
|
const ENOUGH = 170;
|
|
25
24
|
// What is visible of the window: above a phone's keyboard
|
|
26
25
|
// (`visualViewport`), above the bar pinned to it
|
|
27
|
-
// (rich-text-keyboard-bar.tsx) when the field has one
|
|
26
|
+
// (rich-text-keyboard-bar.tsx) when the field has one, and
|
|
28
27
|
// inside every element around the field that clips what overflows it (a
|
|
29
28
|
// card, a dialog's scrolling body).
|
|
30
29
|
function visibleArea(field) {
|
|
@@ -84,7 +83,6 @@ export function RichTextSlashMenu({ id, view, at, field, items, active, onHighli
|
|
|
84
83
|
window.visualViewport?.removeEventListener('resize', update);
|
|
85
84
|
};
|
|
86
85
|
}, [view, at, field, menu, items.length]);
|
|
87
|
-
// The highlighted item stays in sight.
|
|
88
86
|
useLayoutEffect(() => {
|
|
89
87
|
menu?.querySelector(`#${CSS.escape(slashOptionId(id, active))}`)?.scrollIntoView({ block: 'nearest' });
|
|
90
88
|
}, [menu, id, active]);
|
|
@@ -97,7 +95,7 @@ export function RichTextSlashMenu({ id, view, at, field, items, active, onHighli
|
|
|
97
95
|
!placement && 'invisible'), children: items.map((item, index) => {
|
|
98
96
|
const Icon = item.icon;
|
|
99
97
|
return (_jsxs("div", { id: slashOptionId(id, index), role: "option", "aria-selected": index === active,
|
|
100
|
-
// 44px rows on a touch screen
|
|
98
|
+
// 44px rows on a touch screen.
|
|
101
99
|
className: "flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 select-none aria-selected:bg-muted pointer-coarse:min-h-11",
|
|
102
100
|
// A press never takes focus from the text.
|
|
103
101
|
onMouseDown: (event) => event.preventDefault(), onMouseMove: () => index !== active && onHighlight(index), onClick: () => onPick(item.id), children: [_jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0" }), item.label] }, item.id));
|
|
@@ -21,8 +21,8 @@ export declare function slashOptionId(listId: string, index: number): string;
|
|
|
21
21
|
/** The plugin: opens on a typed "/", follows the text, closes once the span stops qualifying. */
|
|
22
22
|
export declare function slashPlugin(): Plugin<SlashState>;
|
|
23
23
|
/**
|
|
24
|
-
* A slash menu item: a block, an image (only with the editor's `upload
|
|
25
|
-
*
|
|
24
|
+
* A slash menu item: a block, an image (only with the editor's `upload`)
|
|
25
|
+
* or the new page (only with the app's `onCreatePage`).
|
|
26
26
|
*/
|
|
27
27
|
export type SlashItem = Omit<FormatItem, 'id'> & {
|
|
28
28
|
id: FormatId | 'image' | 'page';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// line into that block, the "/…" gone. The menu itself:
|
|
4
4
|
// rich-text-slash-menu.tsx; its keys and ARIA: milkdown-editor.tsx.
|
|
5
5
|
//
|
|
6
|
-
// Any line of text
|
|
6
|
+
// Any line of text: a top-level
|
|
7
7
|
// one or a heading, a list item's, a quote's or a callout's, a table
|
|
8
8
|
// cell's. The menu lists only what can be made there: in a cell, the
|
|
9
9
|
// highlights (a cell holds one line), not a heading or a list.
|
|
@@ -111,7 +111,7 @@ const KEYWORDS = {
|
|
|
111
111
|
// once something's typed ("/warn"), so the list "/" opens with stays short.
|
|
112
112
|
const BLOCKS = FORMAT_GROUPS.flat().filter((item) => KEYWORDS[item.id]);
|
|
113
113
|
BLOCKS.splice(BLOCKS.findIndex((item) => item.id === 'heading3') + 1, 0, ...TOGGLE_HEADING_VARIANTS);
|
|
114
|
-
// An image
|
|
114
|
+
// An image: the file picker, the image going where the "/" was.
|
|
115
115
|
// The Image button's job for an editor with no fixed toolbar
|
|
116
116
|
// (`toolbar="floating"`), and a quicker way with one.
|
|
117
117
|
const IMAGE_ITEM = { id: 'image', label: 'Image', icon: ImageIcon };
|
|
@@ -13,7 +13,7 @@ export interface TableGripsProps {
|
|
|
13
13
|
/**
|
|
14
14
|
* The cell the caret is in when it's in this table and the text has
|
|
15
15
|
* focus, else null: all the grips draw from the editor's state, so a
|
|
16
|
-
* key that doesn't move it re-renders nothing
|
|
16
|
+
* key that doesn't move it re-renders nothing. What a menu offers
|
|
17
17
|
* is read from `view`'s state as it opens.
|
|
18
18
|
*/
|
|
19
19
|
caret: TableCell | null;
|
|
@@ -81,7 +81,6 @@ function stateAt(state, tablePos, cell) {
|
|
|
81
81
|
}
|
|
82
82
|
// How far either side of a column's right edge the pointer can be to take it.
|
|
83
83
|
const EDGE_REACH = 6;
|
|
84
|
-
// How much Narrower and Wider change a column.
|
|
85
84
|
const WIDTH_STEP = 16;
|
|
86
85
|
// The column whose right edge is nearest a point within the table, if one's in reach.
|
|
87
86
|
function edgeAt(table, box, x, y) {
|
|
@@ -323,7 +322,7 @@ export function TableGrips({ view, caret, getPos, frame, box, table, readOnly, o
|
|
|
323
322
|
const rowColor = there && tableColorEnabled(there, 'row');
|
|
324
323
|
const finalFocus = () => text() ?? true;
|
|
325
324
|
const grip = 'pointer-events-auto absolute flex items-center justify-center rounded-sm border border-border bg-muted text-muted-foreground shadow-xs outline-none hover:bg-primary hover:text-primary-foreground data-popup-open:bg-primary data-popup-open:text-primary-foreground ' +
|
|
326
|
-
// On a touch screen, an invisible 40px square round each takes the tap
|
|
325
|
+
// On a touch screen, an invisible 40px square round each takes the tap.
|
|
327
326
|
"pointer-coarse:before:absolute pointer-coarse:before:top-1/2 pointer-coarse:before:left-1/2 pointer-coarse:before:size-10 pointer-coarse:before:-translate-1/2 pointer-coarse:before:content-['']";
|
|
328
327
|
return (_jsxs(_Fragment, { children: [!phone && (_jsxs("div", { ref: edgeHandle, hidden: true, "aria-hidden": "true", "data-slot": "rich-text-table-column-edge", className: "pointer-events-auto absolute z-10 flex w-3 -translate-x-1/2 cursor-col-resize touch-none justify-center", onPointerDown: startDrag, onDoubleClick: () => edge !== null && onWidth(edge, null), children: [_jsx("span", { className: "h-full w-0.5 bg-primary" }), drag && (_jsx("span", { "data-slot": "rich-text-table-column-size", className: "absolute bottom-full mb-1 rounded-sm bg-primary px-1.5 font-mono text-xs whitespace-nowrap text-primary-foreground tabular-nums", children: drag.label }))] })), _jsxs(DropdownMenu, { open: open === 'column' || open === 'cell', onOpenChange: openMenu('column'), children: [_jsx(DropdownMenuTrigger, { tabIndex: -1, "aria-label": menuCell ? `Column: ${columnName(menuCell.column)}` : 'Column', ref: columnGrip, "data-slot": "rich-text-table-column-grip", className: cn(grip, 'h-3.5 w-6 -translate-x-1/2 -translate-y-1/2'), children: _jsx(GripHorizontalIcon, { "aria-hidden": "true", className: "size-3" }) }), _jsx(DropdownMenuContent, { className: "w-56", "data-rich-text-menu": "", finalFocus: finalFocus, children: open === 'cell' ? (_jsxs(_Fragment, { children: [menuCell && menuCell.row > 0 && (_jsxs(_Fragment, { children: [colorGroup('cell', 'Cell Colour'), _jsx(DropdownMenuSeparator, {})] })), _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Row" }), items(ROW_ITEMS)] }), _jsx(DropdownMenuSeparator, {}), columnItems(false, menuCell ? `Column: ${columnName(menuCell.column)}` : 'Column')] })) : (columnItems(true)) })] }), _jsxs(DropdownMenu, { open: open === 'row', onOpenChange: openMenu('row'), children: [_jsx(DropdownMenuTrigger, { tabIndex: -1, "aria-label": menuCell ? (menuCell.row === 0 ? 'Header Row' : `Row ${menuCell.row}`) : 'Row', ref: rowGrip, "data-slot": "rich-text-table-row-grip", className: cn(grip, 'h-6 w-3.5 -translate-x-1/2 -translate-y-1/2'), children: _jsx(GripVerticalIcon, { "aria-hidden": "true", className: "size-3" }) }), _jsxs(DropdownMenuContent, { className: "w-56", "data-rich-text-menu": "", finalFocus: finalFocus, children: [_jsx(DropdownMenuGroup, { children: items(ROW_ITEMS) }), rowColor && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), colorGroup('row', 'Colour Row')] }))] })] })] }));
|
|
329
328
|
}
|
|
@@ -7,7 +7,7 @@ export declare const taskInputRule: import("@milkdown/utils").$InputRule;
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function splitTaskItem(state: EditorState, dispatch: (tr: Transaction) => void): boolean;
|
|
9
9
|
/**
|
|
10
|
-
* A task item's box in its hit area
|
|
10
|
+
* A task item's box in its hit area: the box as drawn, in a
|
|
11
11
|
* label whose invisible 40px square, on a touch screen, takes the tap
|
|
12
12
|
* (a press on a label is its checkbox's), and the item's row 40px tall
|
|
13
13
|
* there, so two items' squares never overlap. A laptop is unchanged.
|
|
@@ -71,7 +71,7 @@ export function splitTaskItem(state, dispatch) {
|
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
* A task item's box in its hit area
|
|
74
|
+
* A task item's box in its hit area: the box as drawn, in a
|
|
75
75
|
* label whose invisible 40px square, on a touch screen, takes the tap
|
|
76
76
|
* (a press on a label is its checkbox's), and the item's row 40px tall
|
|
77
77
|
* there, so two items' squares never overlap. A laptop is unchanged.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Whether the editor is on a touch screen
|
|
1
|
+
// Whether the editor is on a touch screen: where its toolbar
|
|
2
2
|
// is the bar pinned to the keyboard (rich-text-keyboard-bar.tsx), the
|
|
3
3
|
// floating bar over selected words gives way to the system's own, and the
|
|
4
4
|
// slash menu is capped to what the keyboard leaves visible.
|