@charcuterie/ui 3.19.2 → 3.21.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/Board/BoardCard.d.ts +95 -22
- package/dist/Board/BoardCard.d.ts.map +1 -1
- package/dist/Board/BoardCard.js +18 -2
- package/dist/Board/BoardCard.js.map +1 -1
- package/dist/MarkdownEditor/markdownSpans.d.ts +17 -4
- package/dist/MarkdownEditor/markdownSpans.d.ts.map +1 -1
- package/dist/MarkdownEditor/markdownSpans.js.map +1 -1
- package/dist/MarkdownLine/MarkdownLine.d.ts +104 -0
- package/dist/MarkdownLine/MarkdownLine.d.ts.map +1 -0
- package/dist/MarkdownLine/MarkdownLine.js +187 -0
- package/dist/MarkdownLine/MarkdownLine.js.map +1 -0
- package/dist/MarkdownLine/inlineMarkdown.d.ts +82 -0
- package/dist/MarkdownLine/inlineMarkdown.d.ts.map +1 -0
- package/dist/MarkdownLine/inlineMarkdown.js +509 -0
- package/dist/MarkdownLine/inlineMarkdown.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/markdownEditorCodeMirror/index.d.ts +1 -1
- package/dist/markdownEditorCodeMirror/index.d.ts.map +1 -1
- package/dist/markdownEditorCodeMirror/index.js +1 -1
- package/dist/markdownEditorCodeMirror/index.js.map +1 -1
- package/dist/markdownEditorCodeMirror/livePreviewRanges.js +1 -1
- package/dist/markdownEditorCodeMirror/livePreviewRanges.js.map +1 -1
- package/dist/safeUrls.d.ts.map +1 -0
- package/dist/safeUrls.js.map +1 -0
- package/package.json +1 -1
- package/src/Board/Board.stories.tsx +167 -0
- package/src/Board/Board.test.tsx +97 -0
- package/src/Board/BoardCard.tsx +135 -27
- package/src/MarkdownEditor/markdownSpans.ts +18 -5
- package/src/MarkdownLine/MarkdownLine.mdx +135 -0
- package/src/MarkdownLine/MarkdownLine.stories.tsx +290 -0
- package/src/MarkdownLine/MarkdownLine.test.tsx +241 -0
- package/src/MarkdownLine/MarkdownLine.tsx +331 -0
- package/src/MarkdownLine/inlineMarkdown.test.ts +253 -0
- package/src/MarkdownLine/inlineMarkdown.ts +768 -0
- package/src/index.ts +9 -2
- package/src/markdownEditorCodeMirror/index.ts +4 -4
- package/src/markdownEditorCodeMirror/livePreviewRanges.ts +1 -1
- package/src/sourceRules.test.ts +17 -1
- package/dist/markdownEditorCodeMirror/safeUrls.d.ts.map +0 -1
- package/dist/markdownEditorCodeMirror/safeUrls.js.map +0 -1
- /package/dist/{markdownEditorCodeMirror/safeUrls.d.ts → safeUrls.d.ts} +0 -0
- /package/dist/{markdownEditorCodeMirror/safeUrls.js → safeUrls.js} +0 -0
- /package/src/{markdownEditorCodeMirror/safeUrls.test.ts → safeUrls.test.ts} +0 -0
- /package/src/{markdownEditorCodeMirror/safeUrls.ts → safeUrls.ts} +0 -0
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
import type { IntentName } from "@charcuterie/tokens";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* for — *"Priority is styled as a leading colour bar, and **never**
|
|
7
|
-
* a coloured word before the title."*
|
|
8
|
-
*
|
|
9
|
-
* Pair it with `accentLabel`. A bar is colour and nothing else, so
|
|
10
|
-
* on its own it fails WCAG 1.4.1 outright and is invisible to
|
|
11
|
-
* every screen reader; the label rides along in a
|
|
12
|
-
* `VisuallyHidden` so the same fact reaches both channels. Docket's
|
|
13
|
-
* first board painted these `--color-danger-9` — a Radix-style
|
|
14
|
-
* scale this token set has never had — so every bar was
|
|
15
|
-
* transparent while every "is it rendered" assertion passed. The
|
|
16
|
-
* families here are `--color-intent-<intent>-<role>`; there is no
|
|
17
|
-
* numeric scale to reach for.
|
|
18
|
-
*/
|
|
19
|
-
accentIntent?: IntentName;
|
|
20
|
-
/** What the bar means, in words. "Priority 0". */
|
|
3
|
+
import type { CardAccentEdge } from "../Card/cardAccentEdge.ts";
|
|
4
|
+
type BoardItemFields = {
|
|
5
|
+
/** What the bar means, in words. "Priority 0", "Movies and Shows". */
|
|
21
6
|
accentLabel?: string;
|
|
22
7
|
/**
|
|
23
8
|
* Under the title and metadata, spanning the card: a live run
|
|
24
9
|
* line, a gate explanation, a due date. A `ProgressBar` goes here.
|
|
25
10
|
*/
|
|
26
11
|
footer?: ReactNode;
|
|
27
|
-
/** Where the title navigates. Routed through `RouterLinkProvider`. */
|
|
28
|
-
href?: string;
|
|
29
12
|
/**
|
|
30
13
|
* Visibly present but not actionable — Docket's *gated*: a task
|
|
31
14
|
* whose phase has not opened yet. Paint only; it does not disable
|
|
@@ -45,12 +28,101 @@ export type BoardItem = {
|
|
|
45
28
|
* beside it when there is room. `Badge` is what goes here.
|
|
46
29
|
*/
|
|
47
30
|
meta?: ReactNode;
|
|
48
|
-
/**
|
|
49
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The card's name, in **words**.
|
|
33
|
+
*
|
|
34
|
+
* Always a plain string, even when `titleContent` draws something
|
|
35
|
+
* richer, because this is what the move handle and the drag
|
|
36
|
+
* announcements are named after — and a control named after a
|
|
37
|
+
* `ReactNode` is a control with no name at all.
|
|
38
|
+
*/
|
|
50
39
|
title: string;
|
|
51
40
|
/** The trailing cluster: an assignee avatar, an elapsed-time chip. */
|
|
52
41
|
trailing?: ReactNode;
|
|
53
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* The leading colour bar, in one of two shapes — and the second one
|
|
45
|
+
* exists because the first cannot follow a corner.
|
|
46
|
+
*
|
|
47
|
+
* `accentIntent` is an inset pill: a `w-1` span inside the card,
|
|
48
|
+
* beside the content. It was built for priority — *"Priority is
|
|
49
|
+
* styled as a leading colour bar, and **never** a coloured word
|
|
50
|
+
* before the title."* An intent is a claim the design system makes
|
|
51
|
+
* (`danger` says what happens if you press the thing), so this arm
|
|
52
|
+
* is for a bar that means a STATE.
|
|
53
|
+
*
|
|
54
|
+
* `accentEdge` is the card's own edge — `Card`'s treatment, the same
|
|
55
|
+
* pseudo-element, so it takes `border-radius: inherit` and wraps the
|
|
56
|
+
* corner at `cq-lg` where this card grows one. It carries a
|
|
57
|
+
* CATEGORICAL colour or a computed one, which is what an identity
|
|
58
|
+
* needs: a project, a repo, a source. The owner asked for exactly
|
|
59
|
+
* this on Docket's board — *"The Board has no colors. That could
|
|
60
|
+
* use project colors on the sides at least."* — after reporting the
|
|
61
|
+
* same treatment missing from the task rows.
|
|
62
|
+
*
|
|
63
|
+
* The two are mutually exclusive by type, not by convention. Both
|
|
64
|
+
* paint a leading bar in the same place, and a card wearing two of
|
|
65
|
+
* them is a card whose leading edge means two things.
|
|
66
|
+
*
|
|
67
|
+
* ⚠️ Either arm pairs with `accentLabel`. A bar is colour and
|
|
68
|
+
* nothing else, so on its own it fails WCAG 1.4.1 outright and is
|
|
69
|
+
* invisible to every screen reader; the label rides along in a
|
|
70
|
+
* `VisuallyHidden` so the same fact reaches both channels. Docket's
|
|
71
|
+
* first board painted its bars `--color-danger-9` — a Radix-style
|
|
72
|
+
* scale this token set has never had — so every bar was transparent
|
|
73
|
+
* while every "is it rendered" assertion passed.
|
|
74
|
+
*/
|
|
75
|
+
type BoardItemAccent = {
|
|
76
|
+
accentEdge?: never;
|
|
77
|
+
accentIntent?: IntentName;
|
|
78
|
+
} | {
|
|
79
|
+
accentEdge: CardAccentEdge;
|
|
80
|
+
accentIntent?: never;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Who owns the card title's link — the board, or the caller.
|
|
84
|
+
*
|
|
85
|
+
* A union rather than three loose optionals, because the two halves
|
|
86
|
+
* genuinely cannot coexist. `href` wraps the title in a `TextLink`
|
|
87
|
+
* and `onSelect` wraps it in a `<button>`; a `titleContent` that
|
|
88
|
+
* contains its own anchor would then be an anchor inside an anchor
|
|
89
|
+
* (which the HTML parser silently un-nests, dropping the rest of the
|
|
90
|
+
* card's link) or an anchor inside a button (which is invalid and
|
|
91
|
+
* unreachable by keyboard). Both look completely correct on screen.
|
|
92
|
+
*
|
|
93
|
+
* So the type refuses the combination outright, and a caller who
|
|
94
|
+
* needs a rich title takes the navigation with it:
|
|
95
|
+
*
|
|
96
|
+
* ```tsx
|
|
97
|
+
* {
|
|
98
|
+
* title: toPlainMarkdownText(task.title),
|
|
99
|
+
* titleContent: (
|
|
100
|
+
* <MarkdownLine href={`/tasks/${task.id}`} value={task.title} />
|
|
101
|
+
* ),
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
type BoardItemTitleLink = {
|
|
106
|
+
/** Where the title navigates. Routed through `RouterLinkProvider`. */
|
|
107
|
+
href?: string;
|
|
108
|
+
/** Fires when there is no `href` — for a board that opens a modal. */
|
|
109
|
+
onSelect?: () => void;
|
|
110
|
+
titleContent?: never;
|
|
111
|
+
} | {
|
|
112
|
+
href?: never;
|
|
113
|
+
onSelect?: never;
|
|
114
|
+
/**
|
|
115
|
+
* Drawn instead of `title`, inside the card's own clamping box
|
|
116
|
+
* — so it still truncates the way every other card does.
|
|
117
|
+
*
|
|
118
|
+
* It **owns its navigation**: the board adds no link around it,
|
|
119
|
+
* which is why `href` and `onSelect` are refused beside it.
|
|
120
|
+
* `title` is still required, and is still the name every
|
|
121
|
+
* control on the card is announced by.
|
|
122
|
+
*/
|
|
123
|
+
titleContent: ReactNode;
|
|
124
|
+
};
|
|
125
|
+
export type BoardItem = BoardItemAccent & BoardItemFields & BoardItemTitleLink;
|
|
54
126
|
export type BoardCardProps = {
|
|
55
127
|
item: BoardItem;
|
|
56
128
|
laneLabel: string;
|
|
@@ -117,4 +189,5 @@ export type BoardCardProps = {
|
|
|
117
189
|
* to keep honest and neither is a fallback for the other.
|
|
118
190
|
*/
|
|
119
191
|
export declare const BoardCard: ({ item, laneLabel, moveIcon, moveTargets, onMoveToLane, onStartDrag, }: BoardCardProps) => ReactNode;
|
|
192
|
+
export {};
|
|
120
193
|
//# sourceMappingURL=BoardCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BoardCard.d.ts","sourceRoot":"","sources":["../../src/Board/BoardCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"BoardCard.d.ts","sourceRoot":"","sources":["../../src/Board/BoardCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAc/D,KAAK,eAAe,GAAG;IACrB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,KAAK,eAAe,GAChB;IAAE,UAAU,CAAC,EAAE,KAAK,CAAC;IAAC,YAAY,CAAC,EAAE,UAAU,CAAA;CAAE,GACjD;IAAE,UAAU,EAAE,cAAc,CAAC;IAAC,YAAY,CAAC,EAAE,KAAK,CAAA;CAAE,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,KAAK,kBAAkB,GACnB;IACE,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,YAAY,CAAC,EAAE,KAAK,CAAA;CACrB,GACD;IACE,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB;;;;;;;;OAQG;IACH,YAAY,EAAE,SAAS,CAAA;CACxB,CAAA;AAEL,MAAM,MAAM,SAAS,GAAG,eAAe,GACrC,eAAe,GACf,kBAAkB,CAAA;AAEpB,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,SAAS,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,0DAA0D;IAC1D,WAAW,EAAE,SAAS;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACtD,8DAA8D;IAC9D,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,WAAW,CAAC,EAAE,CAAC,YAAY,EAAE;QAC3B,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,aAAa,EAAE,WAAW,GAAG,OAAO,CAAA;QACpC,SAAS,EAAE,MAAM,CAAA;KAClB,KAAK,IAAI,CAAA;CACX,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,SAAS,GAAI,wEAOvB,cAAc,KAAG,SAsLnB,CAAA"}
|
package/dist/Board/BoardCard.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Button } from "../Button/Button.js";
|
|
4
|
+
import { getAccentEdgeClassName, getAccentEdgeStyle, } from "../Card/cardAccentEdge.js";
|
|
4
5
|
import { FOCUS_RING_CLASS, INTENT_SOLID_FILL_CLASS, } from "../intentStyles.js";
|
|
5
6
|
import { Menu } from "../Menu/Menu.js";
|
|
6
7
|
import { TextLink } from "../TextLink/TextLink.js";
|
|
@@ -46,13 +47,28 @@ import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
|
46
47
|
*/
|
|
47
48
|
export const BoardCard = ({ item, laneLabel, moveIcon, moveTargets, onMoveToLane, onStartDrag, }) => {
|
|
48
49
|
const [isMenuVisible, setIsMenuVisible] = useState(false);
|
|
49
|
-
const
|
|
50
|
+
const titleBlock = (_jsx("span", { className: "line-clamp-2 cq-sm:line-clamp-none cq-sm:block cq-sm:truncate", children: item.titleContent ?? item.title }));
|
|
50
51
|
return (_jsxs("li", { className: toClassName("group relative flex gap-2 border-border-subtle border-b py-2 pe-1 last:border-b-0",
|
|
51
52
|
// At `cq-lg` the list stops being a list of rows: the
|
|
52
53
|
// divider goes and each card grows its own box. The *list*
|
|
53
54
|
// cannot do this to itself — it is the container, and a
|
|
54
55
|
// container query never matches its own container.
|
|
55
|
-
"cq-lg:mb-2 cq-lg:rounded-lg cq-lg:border cq-lg:bg-surface-raised cq-lg:p-3 cq-lg:shadow-low",
|
|
56
|
+
"cq-lg:mb-2 cq-lg:rounded-lg cq-lg:border cq-lg:bg-surface-raised cq-lg:p-3 cq-lg:shadow-low",
|
|
57
|
+
// The edge is drawn on THIS box, which is why it needs no
|
|
58
|
+
// shape of its own: the box is a row below `cq-lg` and a
|
|
59
|
+
// rounded card above it, and `border-radius: inherit` gives
|
|
60
|
+
// the right answer at both — a straight stripe down a row
|
|
61
|
+
// that has no corner, and a bar that wraps the card's
|
|
62
|
+
// corner once it grows one.
|
|
63
|
+
//
|
|
64
|
+
// `ps-2` is what keeps the content off it. The bar is 3px
|
|
65
|
+
// and overlays rather than displaces, so without this the
|
|
66
|
+
// first mark sits on top of it; at `cq-lg` the card's own
|
|
67
|
+
// `p-3` is already wider than the bar.
|
|
68
|
+
item.accentEdge != null &&
|
|
69
|
+
toClassName("ps-2", getAccentEdgeClassName(item.accentEdge)), item.isDimmed && "opacity-60"), "data-board-card": item.key, ...(item.accentEdge == null
|
|
70
|
+
? {}
|
|
71
|
+
: { style: getAccentEdgeStyle(item.accentEdge) }), children: [item.accentEdge != null && item.accentLabel ? (_jsx(VisuallyHidden, { children: item.accentLabel })) : null, item.accentIntent ? (_jsx("span", { className: toClassName("w-1 shrink-0 self-stretch rounded-full", INTENT_SOLID_FILL_CLASS[item.accentIntent]), children: item.accentLabel ? (_jsx(VisuallyHidden, { children: item.accentLabel })) : null })) : null, _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [_jsxs("div", { className: "flex min-w-0 items-start gap-2", children: [_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1 cq-sm:flex-row cq-sm:items-center cq-sm:gap-2", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-1.5 text-sm leading-snug", children: [item.marks ? (_jsx("span", { className: "flex shrink-0 items-center gap-1 pt-1", children: item.marks })) : null, item.href ? (_jsx(TextLink, { appearance: "standalone", className: "min-w-0 max-w-full font-normal", href: item.href, intent: "neutral", children: titleBlock })) : item.onSelect ? (_jsx("button", { className: toClassName("min-w-0 max-w-full cursor-pointer rounded-xs text-start text-intent-neutral-content hover:underline", FOCUS_RING_CLASS), onClick: item.onSelect, type: "button", children: titleBlock })) : (titleBlock)] }), item.meta ? (_jsx("div", { className: "flex min-w-0 flex-wrap items-center gap-1 cq-sm:shrink-0 cq-sm:flex-nowrap cq-sm:justify-end", children: item.meta })) : null] }), item.trailing || onMoveToLane ? (_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [item.trailing, onMoveToLane && moveTargets.length > 0 ? (_jsx(Menu, { isVisible: isMenuVisible, items: moveTargets.map((target) => ({
|
|
56
72
|
key: target.key,
|
|
57
73
|
label: target.label,
|
|
58
74
|
onSelect: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BoardCard.js","sourceRoot":"","sources":["../../src/Board/BoardCard.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"BoardCard.js","sourceRoot":"","sources":["../../src/Board/BoardCard.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAsB,CAAA;AAE7C,OAAO,EACL,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAkB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAA0B,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAsC,CAAA;AAyJrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,GACI,EAAa,EAAE;IAC9B,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEzD,MAAM,UAAU,GAAG,CAOjB,eAAM,SAAS,EAAC,+DAA+D,YAC5E,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,KAAK,GAC3B,CACR,CAAA;IAED,OAAO,CACL,cACE,SAAS,EAAE,WAAW,CACpB,mFAAmF;QACnF,sDAAsD;QACtD,2DAA2D;QAC3D,wDAAwD;QACxD,mDAAmD;QACnD,6FAA6F;QAC7F,0DAA0D;Q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C;4CAC7C,+CAA+C;4CAC/C,sCAAsC;4CACtC,iBAAiB;4CACjB,SAAS,EAAC,+CAA+C,EACzD,OAAO,EAAE,GAAG,EAAE;gDACZ,gBAAgB,CACd,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAC1B,CAAA;4CACH,CAAC,EACD,aAAa,EAAE,CAAC,YAAY,EAAE,EAAE;gDAC9B,WAAW,EAAE,CAAC,YAAY,CAAC,CAAA;4CAC7B,CAAC,EACD,IAAI,EAAC,IAAI,EACT,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,aAEpC,QAAQ,IAAI,MAAM,EAWnB,KAAC,cAAc,cACZ,QAAQ;wDACP,CAAC,CAAC,QAAQ,IAAI,CAAC,KAAK,kBAAkB,SAAS,EAAE;wDACjD,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,kBAAkB,SAAS,EAAE,GAChC,IACV,GAEX,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,EAEL,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CACb,cAAK,SAAS,EAAC,wCAAwC,YACpD,IAAI,CAAC,MAAM,GACR,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,IACH,CACN,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -57,9 +57,22 @@ export type MarkdownSpan = {
|
|
|
57
57
|
kind: MarkdownSpanKind;
|
|
58
58
|
text: string;
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
/**
|
|
61
|
+
* `MarkdownEditorLine`, not `MarkdownLine` — renamed in 3.18.0 when
|
|
62
|
+
* `MarkdownLine` became a **component**, and a barrel cannot export
|
|
63
|
+
* one name as both a type and a value.
|
|
64
|
+
*
|
|
65
|
+
* The editor's name gave way rather than the component's for two
|
|
66
|
+
* reasons. It is the lower-level of the two — the painted layer's
|
|
67
|
+
* view of one line of a *document*, which is a thing only
|
|
68
|
+
* `MarkdownEditor` has ever needed — and it had no consumer outside
|
|
69
|
+
* this package in any repo in the fleet, checked before the rename.
|
|
70
|
+
* A component that renders a title is the name a call site reaches
|
|
71
|
+
* for; a line-kind union is not.
|
|
72
|
+
*/
|
|
73
|
+
export type MarkdownEditorLineKind = "blockquote" | "code" | "heading" | "list" | "paragraph" | "table" | "thematicBreak";
|
|
74
|
+
export type MarkdownEditorLine = {
|
|
75
|
+
kind: MarkdownEditorLineKind;
|
|
63
76
|
spans: MarkdownSpan[];
|
|
64
77
|
};
|
|
65
78
|
/**
|
|
@@ -79,7 +92,7 @@ export declare const toInlineSpans: (text: string, baseKind?: MarkdownSpanKind)
|
|
|
79
92
|
* caret to sit on, and the painted layer still needs a row so the
|
|
80
93
|
* two layers agree about where line 0 is.
|
|
81
94
|
*/
|
|
82
|
-
export declare const toMarkdownLines: (text: string) =>
|
|
95
|
+
export declare const toMarkdownLines: (text: string) => MarkdownEditorLine[];
|
|
83
96
|
/**
|
|
84
97
|
* Which line the caret is on, from a character offset.
|
|
85
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownSpans.d.ts","sourceRoot":"","sources":["../../src/MarkdownEditor/markdownSpans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,UAAU,GACV,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GACP,eAAe,GACf,QAAQ,GACR,KAAK,CAAA;AAET,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"markdownSpans.d.ts","sourceRoot":"","sources":["../../src/MarkdownEditor/markdownSpans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,UAAU,GACV,SAAS,GACT,MAAM,GACN,QAAQ,GACR,OAAO,GACP,eAAe,GACf,QAAQ,GACR,KAAK,CAAA;AAET,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,sBAAsB,GAC9B,YAAY,GACZ,MAAM,GACN,SAAS,GACT,MAAM,GACN,WAAW,GACX,OAAO,GACP,eAAe,CAAA;AAEnB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,sBAAsB,CAAA;IAC5B,KAAK,EAAE,YAAY,EAAE,CAAA;CACtB,CAAA;AAyFD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,WAAU,gBAA0B,KACnC,YAAY,EAuJd,CAAA;AAkGD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,MAAM,KACX,kBAAkB,EAyBpB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EACZ,QAAQ,MAAM,KACb,MAYF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownSpans.js","sourceRoot":"","sources":["../../src/MarkdownEditor/markdownSpans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;
|
|
1
|
+
{"version":3,"file":"markdownSpans.js","sourceRoot":"","sources":["../../src/MarkdownEditor/markdownSpans.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AA6CH;;;;;GAKG;AACH,MAAM,a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AM,WAAW,GAAG,CACzB,IAAY,EACZ,MAAc,EACN,EAAE;IACV,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IAE1D,IAAI,SAAS,GAAG,CAAC,CAAA;IAEjB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;YACzB,SAAS,IAAI,CAAC,CAAA;QAChB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type MarkdownLineProps = {
|
|
3
|
+
className?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Where the text that is **not** itself a link points — the task
|
|
6
|
+
* a card opens, usually.
|
|
7
|
+
*
|
|
8
|
+
* Given one, every plain run becomes its own anchor to it and a
|
|
9
|
+
* markdown link stays a separate anchor beside them. That is the
|
|
10
|
+
* whole reason this prop exists rather than the caller wrapping
|
|
11
|
+
* the component in an `<a>`: an anchor inside an anchor is invalid
|
|
12
|
+
* HTML, the browser closes the outer one, and the second half of
|
|
13
|
+
* the title silently stops opening the task.
|
|
14
|
+
*
|
|
15
|
+
* Left out, the runs are plain text and only the markdown links
|
|
16
|
+
* are clickable — which is right for a heading, a table cell, or
|
|
17
|
+
* anywhere the line is not itself a destination.
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ **A markdown link splits this into more than one anchor**, and
|
|
20
|
+
* each one is named by the words it actually covers — `Ship`, then
|
|
21
|
+
* `#53`, then `tonight`. That is honest (what is announced is what
|
|
22
|
+
* is on screen, per WCAG 2.5.3) and it is not *good*: `tonight` is
|
|
23
|
+
* a poor name for a link to a task. Giving them all one name was
|
|
24
|
+
* tried and is worse — two links with the same name are ambiguous
|
|
25
|
+
* to anything driving the page by name, which this library's own
|
|
26
|
+
* `expectAgentDrivable` refuses outright. The conclusion is a
|
|
27
|
+
* design one: a link usually belongs in a task's **description**,
|
|
28
|
+
* where it has a sentence around it, rather than in its title.
|
|
29
|
+
*/
|
|
30
|
+
href?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The caller has already wrapped this line in a link — so draw the
|
|
33
|
+
* marks and emit **no anchors at all**, not even for a markdown
|
|
34
|
+
* link.
|
|
35
|
+
*
|
|
36
|
+
* The third and last answer to "who owns the link here", after
|
|
37
|
+
* `href` (this component does) and neither (the markdown links do,
|
|
38
|
+
* and nothing else is clickable). It exists because a whole-card
|
|
39
|
+
* link is a real and common shape — Docket's triage cards wrap the
|
|
40
|
+
* title *and* the body, so middle-click opens the proposal — and
|
|
41
|
+
* inside one, an anchor of any kind is an anchor inside an anchor.
|
|
42
|
+
*
|
|
43
|
+
* That trap has teeth even when no author ever typed a link: a
|
|
44
|
+
* **bare URL autolinks**, so a captured note whose title ends in
|
|
45
|
+
* `https://…` would nest one without anybody writing `[]()`.
|
|
46
|
+
*
|
|
47
|
+
* A markdown link's text still renders, with its marks; it simply
|
|
48
|
+
* does not navigate on its own. The card's link is what a click
|
|
49
|
+
* follows.
|
|
50
|
+
*/
|
|
51
|
+
isInsideLink?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The markdown. **Inline constructs only** — see
|
|
54
|
+
* `inlineMarkdown.ts`; a `#` or a `- ` is a literal character
|
|
55
|
+
* here, and a newline collapses to a space.
|
|
56
|
+
*/
|
|
57
|
+
value: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* One line of markdown, drawn with its inline marks and nothing
|
|
61
|
+
* else.
|
|
62
|
+
*
|
|
63
|
+
* A **title** is what this is for. Docket's cards carry names like
|
|
64
|
+
* ``Ingest 53 movies from `Downloads/MOVIES` into `G:\Movies` ``,
|
|
65
|
+
* and a grid of them set in one flat weight is a wall the eye cannot
|
|
66
|
+
* scan — the parts that differ between two cards are exactly the
|
|
67
|
+
* parts markdown would have marked. So the marks earn their place
|
|
68
|
+
* by making a list of names *scannable*, which is the same argument
|
|
69
|
+
* as the priority bar and the project colour, one layer down.
|
|
70
|
+
*
|
|
71
|
+
* ### It is not a small `MarkdownView`
|
|
72
|
+
*
|
|
73
|
+
* `MarkdownView` renders a document, through CodeMirror, from the
|
|
74
|
+
* optional `@charcuterie/ui/markdown-editor-codemirror` entry point.
|
|
75
|
+
* Neither half of that suits a name: an editor state and a syntax
|
|
76
|
+
* tree per card is an absurd price for forty characters, and the
|
|
77
|
+
* main entry may not reach the CodeMirror stack at all. This parses
|
|
78
|
+
* the inline grammar directly and returns spans.
|
|
79
|
+
*
|
|
80
|
+
* The two therefore have to agree, and `inlineMarkdown.ts` says how
|
|
81
|
+
* that is kept true — most importantly that both call the **same**
|
|
82
|
+
* URL guard, `safeUrls.ts`, which moved up out of the CodeMirror
|
|
83
|
+
* subpath when this landed.
|
|
84
|
+
*
|
|
85
|
+
* ### The `href` prop is the load-bearing one
|
|
86
|
+
*
|
|
87
|
+
* A card title is usually itself a link. A title may also *contain*
|
|
88
|
+
* one. Nested anchors are invalid HTML and the browser silently
|
|
89
|
+
* closes the outer element, so `href` makes the component emit
|
|
90
|
+
* **siblings** — the plain runs anchored to `href`, the markdown
|
|
91
|
+
* links anchored to their own destination — which reads as one
|
|
92
|
+
* continuous line and behaves as two different destinations.
|
|
93
|
+
*
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <MarkdownLine href={`/tasks/${task.id}`} value={task.title} />
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* Anywhere a *string* is required — an `aria-label`, a `title`
|
|
99
|
+
* attribute, `document.title` — call `toPlainMarkdownText` rather
|
|
100
|
+
* than re-stripping the markup with a regex of your own. It is the
|
|
101
|
+
* same parse, so it cannot drift from what is on screen.
|
|
102
|
+
*/
|
|
103
|
+
export declare const MarkdownLine: ({ className, href, isInsideLink, value, }: MarkdownLineProps) => ReactNode;
|
|
104
|
+
//# sourceMappingURL=MarkdownLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownLine.d.ts","sourceRoot":"","sources":["../../src/MarkdownLine/MarkdownLine.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAatC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AA+GD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,YAAY,GAAI,2CAK1B,iBAAiB,KAAG,SAqGtB,CAAA"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { FOCUS_RING_CLASS, INTENT_CONTENT_CLASS, } from "../intentStyles.js";
|
|
4
|
+
import { useRouterLink } from "../RouterLink/RouterLinkProvider.js";
|
|
5
|
+
import { getIsRoutedHref } from "../RouterLink/routerLink.js";
|
|
6
|
+
import { toClassName } from "../toClassName.js";
|
|
7
|
+
import { toInlineMarkdownRuns } from "./inlineMarkdown.js";
|
|
8
|
+
/**
|
|
9
|
+
* The link paint, matched to `.cm-md-link` in the CodeMirror
|
|
10
|
+
* surface's theme rather than to `TextLink`'s.
|
|
11
|
+
*
|
|
12
|
+
* `TextLink` would be the obvious reach and it is the wrong one: it
|
|
13
|
+
* declares `rounded-xs`, a cursor and a hover rule that belong to a
|
|
14
|
+
* link in a paragraph, and — the deciding one — it has no way to
|
|
15
|
+
* inherit the title's own weight, so a link inside a bold title
|
|
16
|
+
* would un-bold itself. Two rules is the whole of what is shared
|
|
17
|
+
* with `.cm-md-link`, and sharing them by value is what keeps the
|
|
18
|
+
* editor and the card showing one answer.
|
|
19
|
+
*/
|
|
20
|
+
const LINK_CLASS = toClassName(INTENT_CONTENT_CLASS.accent, "underline decoration-1 underline-offset-2 hover:decoration-2", FOCUS_RING_CLASS);
|
|
21
|
+
/**
|
|
22
|
+
* `0.9em` and not a step on the type scale.
|
|
23
|
+
*
|
|
24
|
+
* A monospace face at the same `font-size` as the text around it
|
|
25
|
+
* reads bigger — fixed advance width, taller x-height — so a file
|
|
26
|
+
* name in a title would shout. `em` rather than a fixed size so a
|
|
27
|
+
* code span in a 24px heading and one in a 13px card row are both
|
|
28
|
+
* proportional to their line. This is `.cm-md-code`'s rule, copied
|
|
29
|
+
* by value for the same reason as the link's.
|
|
30
|
+
*/
|
|
31
|
+
const CODE_CLASS = "font-mono text-[0.9em] text-intent-info-content";
|
|
32
|
+
/**
|
|
33
|
+
* Position IS the identity here, which is why every `key` in this
|
|
34
|
+
* file is an index.
|
|
35
|
+
*
|
|
36
|
+
* The usual objection to an index key does not reach this component.
|
|
37
|
+
* The list is a **pure function of `value`** — nothing inserts,
|
|
38
|
+
* removes or re-orders a run, and no run holds component state for a
|
|
39
|
+
* key to preserve — so two renders of the same string produce the
|
|
40
|
+
* same runs in the same order, and two renders of different strings
|
|
41
|
+
* are a different line entirely. Content cannot stand in for it: a
|
|
42
|
+
* title like `**Ship** it **Ship**` has two runs with identical text
|
|
43
|
+
* and identical marks, and keying by either would collide.
|
|
44
|
+
*/
|
|
45
|
+
const toMarkedContent = (run, key) => {
|
|
46
|
+
/**
|
|
47
|
+
* AN UNMARKED RUN IS A TEXT NODE, NOT A WRAPPED ONE — and this is
|
|
48
|
+
* an accessibility fix rather than a saving.
|
|
49
|
+
*
|
|
50
|
+
* Every run used to come back inside a keyed `<span>`. It looked
|
|
51
|
+
* identical, and it silently broke every accessible name on the
|
|
52
|
+
* page: the name computation **trims** each element child's
|
|
53
|
+
* contribution before joining them, so
|
|
54
|
+
* `<span>Deduplicate </span><code>~/archive</code><span> by</span>`
|
|
55
|
+
* announces as `Deduplicate~/archiveby`. A text node keeps its
|
|
56
|
+
* spaces, so the same line as text-node / `<code>` / text-node
|
|
57
|
+
* announces correctly.
|
|
58
|
+
*
|
|
59
|
+
* Caught by `Board`'s move handle, which is named after the card's
|
|
60
|
+
* title. On screen the two are indistinguishable — the spaces are
|
|
61
|
+
* still painted either way — which is why `MarkdownLine.test.tsx`
|
|
62
|
+
* asserts the NAME rather than the text.
|
|
63
|
+
*/
|
|
64
|
+
if (!run.isCode &&
|
|
65
|
+
!run.isEmphasis &&
|
|
66
|
+
!run.isStrikethrough &&
|
|
67
|
+
!run.isStrong) {
|
|
68
|
+
return run.text;
|
|
69
|
+
}
|
|
70
|
+
// Innermost first: the element that carries the text, then the
|
|
71
|
+
// marks wrapped around it. `<code>` is innermost because it is the
|
|
72
|
+
// only one that changes the *face* rather than a variation of it.
|
|
73
|
+
let content = run.isCode ? (_jsx("code", { className: CODE_CLASS, children: run.text })) : (run.text);
|
|
74
|
+
if (run.isEmphasis) {
|
|
75
|
+
content = _jsx("em", { children: content });
|
|
76
|
+
}
|
|
77
|
+
if (run.isStrong) {
|
|
78
|
+
content = _jsx("strong", { children: content });
|
|
79
|
+
}
|
|
80
|
+
if (run.isStrikethrough) {
|
|
81
|
+
// `<s>`, not `<del>`. `<del>` means "removed from the document"
|
|
82
|
+
// and carries an editorial history a title does not have; `<s>`
|
|
83
|
+
// is "no longer accurate", which is what a struck-through task
|
|
84
|
+
// name says.
|
|
85
|
+
content = (_jsx("s", { className: "text-content-secondary", children: content }));
|
|
86
|
+
}
|
|
87
|
+
// A `Fragment` rather than a `<span>`: it carries the key React
|
|
88
|
+
// needs for an array child and adds no element to the DOM, so the
|
|
89
|
+
// mark element sits directly inside the anchor and the name
|
|
90
|
+
// computation sees no extra boundary to trim.
|
|
91
|
+
return _jsx(Fragment, { children: content }, key);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* One line of markdown, drawn with its inline marks and nothing
|
|
95
|
+
* else.
|
|
96
|
+
*
|
|
97
|
+
* A **title** is what this is for. Docket's cards carry names like
|
|
98
|
+
* ``Ingest 53 movies from `Downloads/MOVIES` into `G:\Movies` ``,
|
|
99
|
+
* and a grid of them set in one flat weight is a wall the eye cannot
|
|
100
|
+
* scan — the parts that differ between two cards are exactly the
|
|
101
|
+
* parts markdown would have marked. So the marks earn their place
|
|
102
|
+
* by making a list of names *scannable*, which is the same argument
|
|
103
|
+
* as the priority bar and the project colour, one layer down.
|
|
104
|
+
*
|
|
105
|
+
* ### It is not a small `MarkdownView`
|
|
106
|
+
*
|
|
107
|
+
* `MarkdownView` renders a document, through CodeMirror, from the
|
|
108
|
+
* optional `@charcuterie/ui/markdown-editor-codemirror` entry point.
|
|
109
|
+
* Neither half of that suits a name: an editor state and a syntax
|
|
110
|
+
* tree per card is an absurd price for forty characters, and the
|
|
111
|
+
* main entry may not reach the CodeMirror stack at all. This parses
|
|
112
|
+
* the inline grammar directly and returns spans.
|
|
113
|
+
*
|
|
114
|
+
* The two therefore have to agree, and `inlineMarkdown.ts` says how
|
|
115
|
+
* that is kept true — most importantly that both call the **same**
|
|
116
|
+
* URL guard, `safeUrls.ts`, which moved up out of the CodeMirror
|
|
117
|
+
* subpath when this landed.
|
|
118
|
+
*
|
|
119
|
+
* ### The `href` prop is the load-bearing one
|
|
120
|
+
*
|
|
121
|
+
* A card title is usually itself a link. A title may also *contain*
|
|
122
|
+
* one. Nested anchors are invalid HTML and the browser silently
|
|
123
|
+
* closes the outer element, so `href` makes the component emit
|
|
124
|
+
* **siblings** — the plain runs anchored to `href`, the markdown
|
|
125
|
+
* links anchored to their own destination — which reads as one
|
|
126
|
+
* continuous line and behaves as two different destinations.
|
|
127
|
+
*
|
|
128
|
+
* ```tsx
|
|
129
|
+
* <MarkdownLine href={`/tasks/${task.id}`} value={task.title} />
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* Anywhere a *string* is required — an `aria-label`, a `title`
|
|
133
|
+
* attribute, `document.title` — call `toPlainMarkdownText` rather
|
|
134
|
+
* than re-stripping the markup with a regex of your own. It is the
|
|
135
|
+
* same parse, so it cannot drift from what is on screen.
|
|
136
|
+
*/
|
|
137
|
+
export const MarkdownLine = ({ className, href, isInsideLink = false, value, }) => {
|
|
138
|
+
const RouterLink = useRouterLink();
|
|
139
|
+
const runs = toInlineMarkdownRuns(value);
|
|
140
|
+
/**
|
|
141
|
+
* Consecutive runs that share a destination become **one** anchor.
|
|
142
|
+
*
|
|
143
|
+
* Not cosmetic: an anchor per run would make `**Ship** it` two tab
|
|
144
|
+
* stops and two entries in a screen reader's link list for one
|
|
145
|
+
* destination, and would break the hover underline into pieces at
|
|
146
|
+
* every mark boundary.
|
|
147
|
+
*/
|
|
148
|
+
const groups = [];
|
|
149
|
+
for (const run of runs) {
|
|
150
|
+
const last = groups.at(-1);
|
|
151
|
+
if (last && last.href === run.href) {
|
|
152
|
+
last.runs.push(run);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
groups.push({
|
|
156
|
+
...(run.href === undefined ? {} : { href: run.href }),
|
|
157
|
+
runs: [run],
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return (_jsx("span", { className: className, children: groups.map((group, groupIndex) => {
|
|
161
|
+
const content = group.runs.map(toMarkedContent);
|
|
162
|
+
if (isInsideLink) {
|
|
163
|
+
// No anchor, and no link paint either: a word painted as
|
|
164
|
+
// a link that cannot be followed is worse than plain text.
|
|
165
|
+
return (_jsx(Fragment
|
|
166
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: position is the identity — see `toMarkedContent`
|
|
167
|
+
, { children: content }, groupIndex));
|
|
168
|
+
}
|
|
169
|
+
if (group.href !== undefined) {
|
|
170
|
+
// A destination the injected router cannot serve opens in
|
|
171
|
+
// a new tab rather than replacing the app: a title that
|
|
172
|
+
// names a pull request is a reference, and following it
|
|
173
|
+
// should not lose the board the reader was on.
|
|
174
|
+
const isRouted = getIsRoutedHref(group.href);
|
|
175
|
+
const LinkElement = isRouted ? RouterLink : "a";
|
|
176
|
+
return (_jsx(LinkElement, { className: LINK_CLASS, href: group.href, rel: isRouted ? undefined : "noopener noreferrer", target: isRouted ? undefined : "_blank", children: content }, groupIndex));
|
|
177
|
+
}
|
|
178
|
+
if (href === undefined) {
|
|
179
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: position is the identity — see `toMarkedContent`
|
|
180
|
+
return _jsx("span", { children: content }, groupIndex);
|
|
181
|
+
}
|
|
182
|
+
const isRouted = getIsRoutedHref(href);
|
|
183
|
+
const LinkElement = isRouted ? RouterLink : "a";
|
|
184
|
+
return (_jsx(LinkElement, { className: toClassName("hover:underline", FOCUS_RING_CLASS), href: href, children: content }, groupIndex));
|
|
185
|
+
}) }));
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=MarkdownLine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownLine.js","sourceRoot":"","sources":["../../src/MarkdownLine/MarkdownLine.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAsC,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AA4D1D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,GAAG,WAAW,CAC5B,oBAAoB,CAAC,MAAM,EAC3B,8DAA8D,EAC9D,gBAAgB,CACjB,CAAA;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