@charcuterie/ui 3.19.2 → 3.20.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 +54 -5
- package/dist/Board/BoardCard.d.ts.map +1 -1
- package/dist/Board/BoardCard.js +2 -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 +67 -0
- package/src/Board/Board.test.tsx +35 -0
- package/src/Board/BoardCard.tsx +65 -10
- 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,6 +1,6 @@
|
|
|
1
1
|
import type { IntentName } from "@charcuterie/tokens";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
-
|
|
3
|
+
type BoardItemFields = {
|
|
4
4
|
/**
|
|
5
5
|
* The leading colour bar. Priority, in the consumer this was built
|
|
6
6
|
* for — *"Priority is styled as a leading colour bar, and **never**
|
|
@@ -24,8 +24,6 @@ export type BoardItem = {
|
|
|
24
24
|
* line, a gate explanation, a due date. A `ProgressBar` goes here.
|
|
25
25
|
*/
|
|
26
26
|
footer?: ReactNode;
|
|
27
|
-
/** Where the title navigates. Routed through `RouterLinkProvider`. */
|
|
28
|
-
href?: string;
|
|
29
27
|
/**
|
|
30
28
|
* Visibly present but not actionable — Docket's *gated*: a task
|
|
31
29
|
* whose phase has not opened yet. Paint only; it does not disable
|
|
@@ -45,12 +43,62 @@ export type BoardItem = {
|
|
|
45
43
|
* beside it when there is room. `Badge` is what goes here.
|
|
46
44
|
*/
|
|
47
45
|
meta?: ReactNode;
|
|
48
|
-
/**
|
|
49
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The card's name, in **words**.
|
|
48
|
+
*
|
|
49
|
+
* Always a plain string, even when `titleContent` draws something
|
|
50
|
+
* richer, because this is what the move handle and the drag
|
|
51
|
+
* announcements are named after — and a control named after a
|
|
52
|
+
* `ReactNode` is a control with no name at all.
|
|
53
|
+
*/
|
|
50
54
|
title: string;
|
|
51
55
|
/** The trailing cluster: an assignee avatar, an elapsed-time chip. */
|
|
52
56
|
trailing?: ReactNode;
|
|
53
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Who owns the card title's link — the board, or the caller.
|
|
60
|
+
*
|
|
61
|
+
* A union rather than three loose optionals, because the two halves
|
|
62
|
+
* genuinely cannot coexist. `href` wraps the title in a `TextLink`
|
|
63
|
+
* and `onSelect` wraps it in a `<button>`; a `titleContent` that
|
|
64
|
+
* contains its own anchor would then be an anchor inside an anchor
|
|
65
|
+
* (which the HTML parser silently un-nests, dropping the rest of the
|
|
66
|
+
* card's link) or an anchor inside a button (which is invalid and
|
|
67
|
+
* unreachable by keyboard). Both look completely correct on screen.
|
|
68
|
+
*
|
|
69
|
+
* So the type refuses the combination outright, and a caller who
|
|
70
|
+
* needs a rich title takes the navigation with it:
|
|
71
|
+
*
|
|
72
|
+
* ```tsx
|
|
73
|
+
* {
|
|
74
|
+
* title: toPlainMarkdownText(task.title),
|
|
75
|
+
* titleContent: (
|
|
76
|
+
* <MarkdownLine href={`/tasks/${task.id}`} value={task.title} />
|
|
77
|
+
* ),
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
type BoardItemTitleLink = {
|
|
82
|
+
/** Where the title navigates. Routed through `RouterLinkProvider`. */
|
|
83
|
+
href?: string;
|
|
84
|
+
/** Fires when there is no `href` — for a board that opens a modal. */
|
|
85
|
+
onSelect?: () => void;
|
|
86
|
+
titleContent?: never;
|
|
87
|
+
} | {
|
|
88
|
+
href?: never;
|
|
89
|
+
onSelect?: never;
|
|
90
|
+
/**
|
|
91
|
+
* Drawn instead of `title`, inside the card's own clamping box
|
|
92
|
+
* — so it still truncates the way every other card does.
|
|
93
|
+
*
|
|
94
|
+
* It **owns its navigation**: the board adds no link around it,
|
|
95
|
+
* which is why `href` and `onSelect` are refused beside it.
|
|
96
|
+
* `title` is still required, and is still the name every
|
|
97
|
+
* control on the card is announced by.
|
|
98
|
+
*/
|
|
99
|
+
titleContent: ReactNode;
|
|
100
|
+
};
|
|
101
|
+
export type BoardItem = BoardItemFields & BoardItemTitleLink;
|
|
54
102
|
export type BoardCardProps = {
|
|
55
103
|
item: BoardItem;
|
|
56
104
|
laneLabel: string;
|
|
@@ -117,4 +165,5 @@ export type BoardCardProps = {
|
|
|
117
165
|
* to keep honest and neither is a fallback for the other.
|
|
118
166
|
*/
|
|
119
167
|
export declare const BoardCard: ({ item, laneLabel, moveIcon, moveTargets, onMoveToLane, onStartDrag, }: BoardCardProps) => ReactNode;
|
|
168
|
+
export {};
|
|
120
169
|
//# 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;AAatC,
|
|
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;AAatC,KAAK,eAAe,GAAG;IACrB;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,EAAE,UAAU,CAAA;IACzB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAA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B,KAAK,IAAI,CAAA;CACX,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,SAAS,GAAI,wEAOvB,cAAc,KAAG,SA4JnB,CAAA"}
|
package/dist/Board/BoardCard.js
CHANGED
|
@@ -46,13 +46,13 @@ import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
|
46
46
|
*/
|
|
47
47
|
export const BoardCard = ({ item, laneLabel, moveIcon, moveTargets, onMoveToLane, onStartDrag, }) => {
|
|
48
48
|
const [isMenuVisible, setIsMenuVisible] = useState(false);
|
|
49
|
-
const
|
|
49
|
+
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
50
|
return (_jsxs("li", { className: toClassName("group relative flex gap-2 border-border-subtle border-b py-2 pe-1 last:border-b-0",
|
|
51
51
|
// At `cq-lg` the list stops being a list of rows: the
|
|
52
52
|
// divider goes and each card grows its own box. The *list*
|
|
53
53
|
// cannot do this to itself — it is the container, and a
|
|
54
54
|
// 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", item.isDimmed && "opacity-60"), "data-board-card": item.key, children: [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:
|
|
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", item.isDimmed && "opacity-60"), "data-board-card": item.key, children: [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
56
|
key: target.key,
|
|
57
57
|
label: target.label,
|
|
58
58
|
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;AAC7C,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;
|
|
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;AAC7C,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;AAmIrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,I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AC,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,aAAa,GAAG,oBAAoB,CAAA;AAE1C,MAAM,cAAc,GAAG,SAAS,CAAA;AAEhC,MAAM,kBAAkB,GAAG,eAAe,CAAA;AAE1C,MAAM,sBAAsB,GAC1B,wDAAwD,CAAA;AAE1D,MAAM,eAAe,GAAG,eAAe,CAAA;AAEvC,MAAM,mBAAmB,GAAG,8BAA8B,CAAA;AAE1D,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,eAAe,GAAG;IACtB;;;;;;;;;OASG;IACH,QAAQ,EAAE,+CAA+C;IACzD,IA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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;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,GACd,iDAAiD,CAAA;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,eAAe,GAAG,CACtB,GAAsB,EACtB,GAAW,EACA,EAAE;IACb;;;;;;;;;;;;;;;;;OAiBG;IACH,IACE,CAAC,GAAG,CAAC,MAAM;QACX,CAAC,GAAG,CAAC,UAAU;QACf,CAAC,GAAG,CAAC,eAAe;QACpB,CAAC,GAAG,CAAC,QAAQ,EACb,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,CAAA;IACjB,CAAC;IAED,+DAA+D;IAC/D,mEAAmE;I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,CAAA;YACH,CAAC;YAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,iGAAiG;gBACjG,OAAO,yBAAwB,OAAO,IAApB,UAAU,CAAkB,CAAA;YAChD,CAAC;YAED,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;YAEtC,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAA;YAE/C,OAAO,CACL,KAAC,WAAW,IACV,SAAS,EAAE,WAAW,CACpB,iBAAiB,EACjB,gBAAgB,CACjB,EACD,IAAI,EAAE,IAAI,YAIT,OAAO,IAFH,UAAU,CAGH,CACf,CAAA;QACH,CAAC,CAAC,GACG,CACR,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown's **inline** half, parsed into flat runs of marked text.
|
|
3
|
+
*
|
|
4
|
+
* ### Why this is not the CodeMirror parser
|
|
5
|
+
*
|
|
6
|
+
* `@charcuterie/ui/markdown-editor-codemirror` already renders
|
|
7
|
+
* markdown, through `@lezer/markdown`. It is the right answer for a
|
|
8
|
+
* document and the wrong one for a **name**: an editor instance per
|
|
9
|
+
* card is a CodeMirror state, a view, a syntax tree and a decoration
|
|
10
|
+
* set for a string that is usually under sixty characters, and a
|
|
11
|
+
* backlog grid draws dozens of them at once. The whole CodeMirror
|
|
12
|
+
* stack is also an *optional peer* of this package on purpose — the
|
|
13
|
+
* main entry may not reach it, so a title renderer that lives in the
|
|
14
|
+
* main entry cannot borrow it even if the cost were acceptable.
|
|
15
|
+
*
|
|
16
|
+
* So this is a second parser, which is a thing to be nervous about:
|
|
17
|
+
* two parsers are two answers to "what does this markdown mean", and
|
|
18
|
+
* that divergence is exactly the bug the consumer's
|
|
19
|
+
* renderer-agreement test exists to catch. Three things keep it
|
|
20
|
+
* honest:
|
|
21
|
+
*
|
|
22
|
+
* 1. **It is inline-only, and says so.** A `#`, a `>`, a `|` table
|
|
23
|
+
* row and a `- ` list marker are literal characters here. There
|
|
24
|
+
* is no block level to disagree about, because there is no block
|
|
25
|
+
* level.
|
|
26
|
+
* 2. **The URL guard is shared, not copied.** Both surfaces call
|
|
27
|
+
* `toSafeLinkUrl` from `../safeUrls.ts` — one module, one
|
|
28
|
+
* allowlist. It moved up out of the CodeMirror subpath when this
|
|
29
|
+
* landed, for that reason.
|
|
30
|
+
* 3. **The flanking rules are CommonMark's**, not a convenient
|
|
31
|
+
* approximation. That is what makes `ingest_the_files.sh` a file
|
|
32
|
+
* name rather than a title with an italic word in the middle of
|
|
33
|
+
* it, and file names in titles are the case this was built for.
|
|
34
|
+
*
|
|
35
|
+
* ### The shape it produces
|
|
36
|
+
*
|
|
37
|
+
* A **flat** list of runs, not a tree. Marks compose by set union, so
|
|
38
|
+
* `**bold [link](/x) tail**` is three runs that all carry `isStrong`
|
|
39
|
+
* and of which one carries an `href` — which is precisely the shape
|
|
40
|
+
* `MarkdownLine` needs to render a link *beside* the surrounding
|
|
41
|
+
* anchor rather than inside it. A tree would have to be flattened
|
|
42
|
+
* back into this before it could be drawn.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* One run of text, with every mark that covers it.
|
|
46
|
+
*
|
|
47
|
+
* `href` is present only on a run that came from `[text](url)` or
|
|
48
|
+
* from a bare URL — never inherited from the caller's own link. Who
|
|
49
|
+
* the *plain* text points at is `MarkdownLine`'s question, not the
|
|
50
|
+
* parser's.
|
|
51
|
+
*/
|
|
52
|
+
export type InlineMarkdownRun = {
|
|
53
|
+
href?: string;
|
|
54
|
+
isCode: boolean;
|
|
55
|
+
isEmphasis: boolean;
|
|
56
|
+
isStrikethrough: boolean;
|
|
57
|
+
isStrong: boolean;
|
|
58
|
+
text: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The inline runs of `value`, in order.
|
|
62
|
+
*
|
|
63
|
+
* Exported because a consumer occasionally needs the runs without
|
|
64
|
+
* React — Docket's search highlighter walks them to find which run a
|
|
65
|
+
* match landed in — and because it is the seam every test in this
|
|
66
|
+
* directory drives.
|
|
67
|
+
*/
|
|
68
|
+
export declare const toInlineMarkdownRuns: (value: string) => InlineMarkdownRun[];
|
|
69
|
+
/**
|
|
70
|
+
* The same string with its markers **gone** — what the title says,
|
|
71
|
+
* with nothing about how it is painted.
|
|
72
|
+
*
|
|
73
|
+
* This is not a convenience. Every `aria-label`, `title` attribute,
|
|
74
|
+
* `document.title` and confirmation sentence that names a task needs
|
|
75
|
+
* the words without the punctuation, and deriving it from the same
|
|
76
|
+
* parse is the only way it cannot drift from what is on screen. A
|
|
77
|
+
* second regex that "strips markdown" is how the card comes to read
|
|
78
|
+
* `Ingest 53 movies` while the tooltip reads
|
|
79
|
+
* `Ingest 53 movies from `Downloads/MOVIES``.
|
|
80
|
+
*/
|
|
81
|
+
export declare const toPlainMarkdownText: (value: string) => string;
|
|
82
|
+
//# sourceMappingURL=inlineMarkdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineMarkdown.d.ts","sourceRoot":"","sources":["../../src/MarkdownLine/inlineMarkdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAIH;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAoqBD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,KACZ,iBAAiB,EAC8B,CAAA;AAElD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,KACZ,MAGU,CAAA"}
|