@charcuterie/ui 3.3.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +19 -1
- package/dist/Field/Field.js.map +1 -1
- package/dist/MarkdownEditor/MarkdownEditor.d.ts.map +1 -1
- package/dist/MarkdownEditor/MarkdownEditor.js +21 -8
- package/dist/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/MarkdownEditor/markdownCommands.d.ts +32 -0
- package/dist/MarkdownEditor/markdownCommands.d.ts.map +1 -1
- package/dist/MarkdownEditor/markdownCommands.js +47 -0
- package/dist/MarkdownEditor/markdownCommands.js.map +1 -1
- package/dist/MarkdownEditor/markdownSpans.d.ts.map +1 -1
- package/dist/MarkdownEditor/markdownSpans.js +30 -0
- package/dist/MarkdownEditor/markdownSpans.js.map +1 -1
- package/dist/markdownEditorCodeMirror/MarkdownEditorCodeMirror.d.ts +93 -0
- package/dist/markdownEditorCodeMirror/MarkdownEditorCodeMirror.d.ts.map +1 -0
- package/dist/markdownEditorCodeMirror/MarkdownEditorCodeMirror.js +545 -0
- package/dist/markdownEditorCodeMirror/MarkdownEditorCodeMirror.js.map +1 -0
- package/dist/markdownEditorCodeMirror/index.d.ts +16 -0
- package/dist/markdownEditorCodeMirror/index.d.ts.map +1 -0
- package/dist/markdownEditorCodeMirror/index.js +14 -0
- package/dist/markdownEditorCodeMirror/index.js.map +1 -0
- package/dist/markdownEditorCodeMirror/livePreview.d.ts +40 -0
- package/dist/markdownEditorCodeMirror/livePreview.d.ts.map +1 -0
- package/dist/markdownEditorCodeMirror/livePreview.js +428 -0
- package/dist/markdownEditorCodeMirror/livePreview.js.map +1 -0
- package/dist/markdownEditorCodeMirror/livePreviewRanges.d.ts +128 -0
- package/dist/markdownEditorCodeMirror/livePreviewRanges.d.ts.map +1 -0
- package/dist/markdownEditorCodeMirror/livePreviewRanges.js +345 -0
- package/dist/markdownEditorCodeMirror/livePreviewRanges.js.map +1 -0
- package/package.json +36 -1
- package/src/Accordion/Accordion.stories.tsx +1 -1
- package/src/AdaptiveGrid/AdaptiveGrid.stories.tsx +1 -1
- package/src/Alert/Alert.stories.tsx +1 -1
- package/src/Badge/Badge.stories.tsx +1 -1
- package/src/Board/Board.stories.tsx +1 -1
- package/src/Button/Button.stories.tsx +1 -1
- package/src/ButtonLink/ButtonLink.stories.tsx +1 -1
- package/src/Card/Card.stories.tsx +1 -1
- package/src/Checkbox/Checkbox.stories.tsx +1 -1
- package/src/ColorSchemeSwitcher/ColorSchemeSwitcher.stories.tsx +1 -1
- package/src/ColorSchemeToggle/ColorSchemeToggle.stories.tsx +1 -1
- package/src/Combobox/Combobox.stories.tsx +1 -1
- package/src/DataTable/DataTable.stories.tsx +1 -1
- package/src/DatePicker/DatePicker.stories.tsx +1 -1
- package/src/Dialog/Dialog.stories.tsx +1 -1
- package/src/EmptyState/EmptyState.stories.tsx +1 -1
- package/src/Field/Field.stories.tsx +1 -1
- package/src/Field/Field.test.tsx +35 -0
- package/src/Field/Field.tsx +18 -0
- package/src/FileDropZone/FileDropZone.stories.tsx +1 -1
- package/src/Header/Header.stories.tsx +1 -1
- package/src/IconButton/IconButton.stories.tsx +1 -1
- package/src/Lightbox/Lightbox.stories.tsx +1 -1
- package/src/Listbox/Listbox.stories.tsx +1 -1
- package/src/LiveStatusIndicator/LiveStatusIndicator.stories.tsx +1 -1
- package/src/LogViewer/LogViewer.stories.tsx +1 -1
- package/src/Main/Main.stories.tsx +1 -1
- package/src/MarkdownEditor/MarkdownEditor.stories.tsx +1 -1
- package/src/MarkdownEditor/MarkdownEditor.tsx +33 -7
- package/src/MarkdownEditor/markdownCommands.test.ts +55 -0
- package/src/MarkdownEditor/markdownCommands.ts +60 -0
- package/src/MarkdownEditor/markdownSpans.test.ts +65 -0
- package/src/MarkdownEditor/markdownSpans.ts +35 -0
- package/src/MediaTile/MediaTile.stories.tsx +1 -1
- package/src/Menu/Menu.stories.tsx +1 -1
- package/src/Modal/Modal.stories.tsx +1 -1
- package/src/Picker/Picker.stories.tsx +1 -1
- package/src/Popover/Popover.stories.tsx +1 -1
- package/src/ProgressBar/ProgressBar.stories.tsx +1 -1
- package/src/QueryBuilder/QueryBuilder.stories.tsx +1 -1
- package/src/RadioGroup/RadioGroup.stories.tsx +1 -1
- package/src/Rail/Rail.stories.tsx +1 -1
- package/src/SegmentedControl/SegmentedControl.stories.tsx +1 -1
- package/src/Select/Select.stories.tsx +17 -6
- package/src/Shell/Shell.stories.tsx +1 -1
- package/src/Skeleton/Skeleton.stories.tsx +1 -1
- package/src/SortableTableHeader/SortableTableHeader.stories.tsx +1 -1
- package/src/Spinner/Spinner.stories.tsx +1 -1
- package/src/Swatch/Swatch.stories.tsx +1 -1
- package/src/Switch/Switch.stories.tsx +1 -1
- package/src/Tabs/Tabs.stories.tsx +1 -1
- package/src/TextLink/TextLink.stories.tsx +1 -1
- package/src/Toast/Toast.stories.tsx +1 -1
- package/src/Toolbar/Toolbar.stories.tsx +1 -1
- package/src/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/VisuallyHidden/VisuallyHidden.stories.tsx +1 -1
- package/src/markdownEditorCodeMirror/MarkdownEditorCodeMirror.mdx +144 -0
- package/src/markdownEditorCodeMirror/MarkdownEditorCodeMirror.stories.tsx +147 -0
- package/src/markdownEditorCodeMirror/MarkdownEditorCodeMirror.tsx +866 -0
- package/src/markdownEditorCodeMirror/index.ts +26 -0
- package/src/markdownEditorCodeMirror/livePreview.ts +535 -0
- package/src/markdownEditorCodeMirror/livePreviewRanges.test.ts +431 -0
- package/src/markdownEditorCodeMirror/livePreviewRanges.ts +581 -0
- package/src/sourceRules.test.ts +20 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useUniqueId } from "@charcuterie/logic";
|
|
3
|
+
import { defaultKeymap, history, historyKeymap, } from "@codemirror/commands";
|
|
4
|
+
import { markdown, markdownLanguage, } from "@codemirror/lang-markdown";
|
|
5
|
+
import { Compartment, EditorState } from "@codemirror/state";
|
|
6
|
+
import { EditorView, keymap, placeholder as placeholderExtension, } from "@codemirror/view";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { continueList, getMinimalEdit, indentLines, insertLink, insertText, isLinkPaste, MARKDOWN_LINE_PREFIXES, outdentLines, toggleHeading, toggleInlineMarker, toggleLinePrefix, toMarkdownImage, wrapSelectionInLink, } from "../MarkdownEditor/markdownCommands.js";
|
|
9
|
+
import { Switch } from "../Switch/Switch.js";
|
|
10
|
+
import { Toolbar } from "../Toolbar/Toolbar.js";
|
|
11
|
+
import { toClassName } from "../toClassName.js";
|
|
12
|
+
import { livePreview, setLivePreviewRawMode, } from "./livePreview.js";
|
|
13
|
+
const isImageFile = (file) => file.type.startsWith("image/");
|
|
14
|
+
const readSelection = (view) => {
|
|
15
|
+
const { main } = view.state.selection;
|
|
16
|
+
return {
|
|
17
|
+
selectionEnd: main.to,
|
|
18
|
+
selectionStart: main.from,
|
|
19
|
+
text: view.state.doc.toString(),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Apply a pure command's result as a **minimal** change.
|
|
24
|
+
*
|
|
25
|
+
* `getMinimalEdit` earns its keep differently here than in the
|
|
26
|
+
* textarea sibling. There it was about not wiping the browser's own
|
|
27
|
+
* undo stack; here CodeMirror's history would happily record a
|
|
28
|
+
* document-sized replacement — and then Ctrl+Z undoes the whole
|
|
29
|
+
* description instead of the bold toggle that caused it.
|
|
30
|
+
*
|
|
31
|
+
* Module scope, not a closure, because it is a pure function of its
|
|
32
|
+
* two arguments. That is not a lint dodge: a helper defined inside
|
|
33
|
+
* the component is a new identity every render, and this one gets
|
|
34
|
+
* captured by extensions that are built exactly once.
|
|
35
|
+
*/
|
|
36
|
+
const applyEdit = (view, next) => {
|
|
37
|
+
const current = view.state.doc.toString();
|
|
38
|
+
const edit = getMinimalEdit(current, next.text);
|
|
39
|
+
view.dispatch({
|
|
40
|
+
changes: {
|
|
41
|
+
from: edit.start,
|
|
42
|
+
insert: edit.text,
|
|
43
|
+
to: edit.end,
|
|
44
|
+
},
|
|
45
|
+
selection: {
|
|
46
|
+
anchor: next.selectionStart,
|
|
47
|
+
head: next.selectionEnd,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
view.focus();
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Upload one file, with a **markdown** placeholder holding the
|
|
54
|
+
* caret's place while the request is in flight.
|
|
55
|
+
*
|
|
56
|
+
* The placeholder is real text in the document rather than an
|
|
57
|
+
* overlay, because the user keeps typing during an upload and the
|
|
58
|
+
* insertion point has to travel with what they type. It carries a
|
|
59
|
+
* counter so two files of the same name do not resolve into each
|
|
60
|
+
* other's slot, and it is markdown like everything else — a failed
|
|
61
|
+
* upload leaves a document the user can read and fix, not a
|
|
62
|
+
* dangling widget.
|
|
63
|
+
*/
|
|
64
|
+
const uploadImage = async ({ count, file, handlers, setMessage, view, }) => {
|
|
65
|
+
const { onUploadError, onUploadImage } = handlers;
|
|
66
|
+
if (!onUploadImage) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const marker = ``;
|
|
70
|
+
applyEdit(view, insertText(readSelection(view), marker));
|
|
71
|
+
setMessage(`Uploading ${file.name}`);
|
|
72
|
+
const replaceMarker = (insertion) => {
|
|
73
|
+
const text = view.state.doc.toString();
|
|
74
|
+
const start = text.indexOf(marker);
|
|
75
|
+
if (start === -1) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const caret = start + insertion.length;
|
|
79
|
+
applyEdit(view, {
|
|
80
|
+
selectionEnd: caret,
|
|
81
|
+
selectionStart: caret,
|
|
82
|
+
text: text.slice(0, start) +
|
|
83
|
+
insertion +
|
|
84
|
+
text.slice(start + marker.length),
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
try {
|
|
88
|
+
const uploaded = await onUploadImage(file);
|
|
89
|
+
replaceMarker(toMarkdownImage({
|
|
90
|
+
alt: uploaded.alt ?? file.name,
|
|
91
|
+
url: uploaded.url,
|
|
92
|
+
}));
|
|
93
|
+
setMessage(`Inserted ${file.name}`);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
replaceMarker("");
|
|
97
|
+
setMessage(`Could not upload ${file.name}`);
|
|
98
|
+
onUploadError?.(file, error);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* The live-preview markdown editor: Obsidian's model, on CodeMirror.
|
|
103
|
+
*
|
|
104
|
+
* This is the **opt-in** sibling of `MarkdownEditor`, and picking
|
|
105
|
+
* between them is a real decision rather than a preference:
|
|
106
|
+
*
|
|
107
|
+
* | | `MarkdownEditor` | this |
|
|
108
|
+
* | --- | --- | --- |
|
|
109
|
+
* | Surface | `<textarea>` + painted layer | CodeMirror 6 |
|
|
110
|
+
* | New dependency | **none** | ~176 KB gz of optional peer |
|
|
111
|
+
* | Markers | dimmed, never hidden | **concealed** until the caret arrives |
|
|
112
|
+
* | Headings | weight and colour only | **actually larger** |
|
|
113
|
+
* | Images | shown as `` | **rendered in place** |
|
|
114
|
+
* | Undo, IME | the platform's own | CodeMirror's |
|
|
115
|
+
*
|
|
116
|
+
* The default is still the textarea. A component library that makes
|
|
117
|
+
* every consumer install an editor core to render a description
|
|
118
|
+
* field has made the wrong trade, which is why this lives behind
|
|
119
|
+
* `@charcuterie/ui/markdown-editor-codemirror` with every CodeMirror
|
|
120
|
+
* package as an **optional** peer: a consumer that never imports
|
|
121
|
+
* this subpath resolves, installs and audits none of it.
|
|
122
|
+
*
|
|
123
|
+
* ## What is the same, and it is the important part
|
|
124
|
+
*
|
|
125
|
+
* **Markdown is the stored value, byte for byte.** There is no
|
|
126
|
+
* document model here and no serialiser. CodeMirror's state holds
|
|
127
|
+
* the markdown *text*; live preview is a set of decorations
|
|
128
|
+
* *over* that text; concealing `**` hides two characters that are
|
|
129
|
+
* still in the document and still in `onChange`. Every command is
|
|
130
|
+
* the same pure `markdownCommands.ts` the sibling uses, returning
|
|
131
|
+
* markdown in and markdown out.
|
|
132
|
+
*
|
|
133
|
+
* That distinction is the whole reason this is not TipTap or
|
|
134
|
+
* Lexical. Those invert it — their document model is authoritative
|
|
135
|
+
* and markdown becomes a lossy *export* — and the tracker Docket
|
|
136
|
+
* replaces died of exactly that: HTML in a field it later read back
|
|
137
|
+
* as text. An editor core would have been easier to build and is
|
|
138
|
+
* the one thing that could not be allowed.
|
|
139
|
+
*
|
|
140
|
+
* ## What genuinely costs something
|
|
141
|
+
*
|
|
142
|
+
* The `<textarea>` sibling gets caret movement, IME composition,
|
|
143
|
+
* spellcheck, the platform undo stack and `role="textbox"` from the
|
|
144
|
+
* browser, tested by the vendors. A `contenteditable` re-earns each
|
|
145
|
+
* of those, and CodeMirror is the reason that is acceptable rather
|
|
146
|
+
* than reckless: it is the most heavily exercised implementation of
|
|
147
|
+
* that re-earning in the ecosystem. It is still a re-implementation,
|
|
148
|
+
* and that is the honest cost of this subpath.
|
|
149
|
+
*
|
|
150
|
+
* ## Clicking a link opens it
|
|
151
|
+
*
|
|
152
|
+
* Obsidian's behaviour, not VS Code's: where the markup is hidden, a
|
|
153
|
+
* link that looks like a link acts like one. The trade is that you
|
|
154
|
+
* cannot click *into* link text to edit it — arrow in from the edge,
|
|
155
|
+
* or flip the raw-markdown toggle, which is exactly what it is for.
|
|
156
|
+
*/
|
|
157
|
+
export const MarkdownEditorCodeMirror = ({ className, defaultValue = "", icons, isDisabled = false, isRawModeDefault = false, isReadOnly = false, label, onChange, onUploadError, onUploadImage, placeholder, rawModeLabel = "Markdown source", toolbarLabel = "Markdown formatting", ...receivedSlotProps }) => {
|
|
158
|
+
const baseId = useUniqueId();
|
|
159
|
+
const hintId = `${baseId}-hint`;
|
|
160
|
+
const hostRef = useRef(null);
|
|
161
|
+
const viewRef = useRef(null);
|
|
162
|
+
const uploadCount = useRef(0);
|
|
163
|
+
const editabilityRef = useRef(new Compartment());
|
|
164
|
+
const [isRawMode, setIsRawMode] = useState(isRawModeDefault);
|
|
165
|
+
const [uploadMessage, setUploadMessage] = useState("");
|
|
166
|
+
/**
|
|
167
|
+
* Callbacks reach the editor through a ref, never a closure.
|
|
168
|
+
*
|
|
169
|
+
* The `EditorView` is built once and lives for the component's
|
|
170
|
+
* whole life — rebuilding it on every render would discard the
|
|
171
|
+
* undo history and the caret. So its extensions capture *this*
|
|
172
|
+
* object, and the render loop keeps the object current.
|
|
173
|
+
*/
|
|
174
|
+
const handlersRef = useRef({
|
|
175
|
+
onChange,
|
|
176
|
+
onUploadError,
|
|
177
|
+
onUploadImage,
|
|
178
|
+
});
|
|
179
|
+
handlersRef.current = {
|
|
180
|
+
onChange,
|
|
181
|
+
onUploadError,
|
|
182
|
+
onUploadImage,
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* The uncontrolled contract, made explicit.
|
|
186
|
+
*
|
|
187
|
+
* These are the props that are **initial only**, frozen at mount
|
|
188
|
+
* in a ref rather than read from the render closure. Writing it
|
|
189
|
+
* this way says the quiet part out loud — changing `placeholder`
|
|
190
|
+
* later genuinely does nothing — and it keeps the build-once
|
|
191
|
+
* effect honestly dependency-free instead of suppressing a lint
|
|
192
|
+
* rule that is, in every other component here, correct.
|
|
193
|
+
*/
|
|
194
|
+
const mountRef = useRef({
|
|
195
|
+
ariaDescribedBy: receivedSlotProps["aria-describedby"],
|
|
196
|
+
defaultValue,
|
|
197
|
+
hintId,
|
|
198
|
+
id: receivedSlotProps.id,
|
|
199
|
+
isRawModeDefault,
|
|
200
|
+
label,
|
|
201
|
+
placeholder,
|
|
202
|
+
});
|
|
203
|
+
const runCommand = (command) => {
|
|
204
|
+
const view = viewRef.current;
|
|
205
|
+
if (!view || isDisabled || isReadOnly) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
applyEdit(view, command(readSelection(view)));
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Built exactly once, and the empty dependency array is the whole
|
|
212
|
+
* point rather than an oversight.
|
|
213
|
+
*
|
|
214
|
+
* An `EditorView` owns the caret, the selection, the scroll
|
|
215
|
+
* position and the undo history. Rebuilding it throws all four
|
|
216
|
+
* away — so a dependency list here would mean that typing a
|
|
217
|
+
* description, then having a parent re-render with a new
|
|
218
|
+
* `placeholder` string, silently drops the user's undo stack
|
|
219
|
+
* mid-sentence. The values read inside are the *initial* half of
|
|
220
|
+
* the uncontrolled contract; everything that can legitimately
|
|
221
|
+
* change afterwards reaches the view through a compartment
|
|
222
|
+
* (editability) or through `handlersRef` (the callbacks).
|
|
223
|
+
*
|
|
224
|
+
* Swapping the document itself — Docket opening a different task —
|
|
225
|
+
* is a `key`, which is honest about the old history belonging to
|
|
226
|
+
* the old document.
|
|
227
|
+
*/
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
const host = hostRef.current;
|
|
230
|
+
if (!host) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const view = new EditorView({
|
|
234
|
+
parent: host,
|
|
235
|
+
state: EditorState.create({
|
|
236
|
+
doc: mountRef.current.defaultValue,
|
|
237
|
+
extensions: [
|
|
238
|
+
history(),
|
|
239
|
+
// `Tab` is deliberately absent, at every level: indenting
|
|
240
|
+
// with it is the convention in editors that own the whole
|
|
241
|
+
// page, and inside a form it is a keyboard trap (WCAG
|
|
242
|
+
// 2.1.2). `indentWithTab` is the extension that would add
|
|
243
|
+
// it, and it is not here. Indent is Ctrl+] / Ctrl+[.
|
|
244
|
+
keymap.of([
|
|
245
|
+
{
|
|
246
|
+
key: "Enter",
|
|
247
|
+
run: (target) => {
|
|
248
|
+
const continued = continueList(readSelection(target));
|
|
249
|
+
if (!continued) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
applyEdit(target, continued);
|
|
253
|
+
return true;
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
key: "Mod-b",
|
|
258
|
+
run: (target) => {
|
|
259
|
+
applyEdit(target, toggleInlineMarker(readSelection(target), "**"));
|
|
260
|
+
return true;
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
key: "Mod-i",
|
|
265
|
+
run: (target) => {
|
|
266
|
+
applyEdit(target, toggleInlineMarker(readSelection(target), "_"));
|
|
267
|
+
return true;
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
key: "Mod-e",
|
|
272
|
+
run: (target) => {
|
|
273
|
+
applyEdit(target, toggleInlineMarker(readSelection(target), "`"));
|
|
274
|
+
return true;
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
key: "Mod-k",
|
|
279
|
+
run: (target) => {
|
|
280
|
+
applyEdit(target, insertLink(readSelection(target)));
|
|
281
|
+
return true;
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
key: "Mod-]",
|
|
286
|
+
run: (target) => {
|
|
287
|
+
applyEdit(target, indentLines(readSelection(target)));
|
|
288
|
+
return true;
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
key: "Mod-[",
|
|
293
|
+
run: (target) => {
|
|
294
|
+
applyEdit(target, outdentLines(readSelection(target)));
|
|
295
|
+
return true;
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
...historyKeymap,
|
|
299
|
+
...defaultKeymap,
|
|
300
|
+
]),
|
|
301
|
+
// GFM, not strict CommonMark — which is what autolinks a
|
|
302
|
+
// bare URL, renders task lists, and parses tables. A
|
|
303
|
+
// pasted link becoming a link with nothing typed around
|
|
304
|
+
// it falls straight out of this one argument.
|
|
305
|
+
markdown({ base: markdownLanguage }),
|
|
306
|
+
EditorView.lineWrapping,
|
|
307
|
+
livePreview(),
|
|
308
|
+
mountRef.current.placeholder
|
|
309
|
+
? placeholderExtension(mountRef.current.placeholder)
|
|
310
|
+
: [],
|
|
311
|
+
EditorView.contentAttributes.of({
|
|
312
|
+
...(mountRef.current.label
|
|
313
|
+
? { "aria-label": mountRef.current.label }
|
|
314
|
+
: {}),
|
|
315
|
+
/**
|
|
316
|
+
* Named by the `Field` above, when there is one and no
|
|
317
|
+
* `label` was passed.
|
|
318
|
+
*
|
|
319
|
+
* The sibling editor needs none of this: a `<textarea>`
|
|
320
|
+
* is a **labelable** element, so `Field`'s
|
|
321
|
+
* `<label htmlFor>` names it and that is the end of it.
|
|
322
|
+
* This surface is a `div[role="textbox"]`, which is not
|
|
323
|
+
* labelable — `htmlFor` pointing at it names nothing,
|
|
324
|
+
* silently, and axe was the only thing that caught it.
|
|
325
|
+
*
|
|
326
|
+
* `Field` gives its `<label>` the id below for exactly
|
|
327
|
+
* this, and `Field.test.tsx` pins the format.
|
|
328
|
+
*/
|
|
329
|
+
...(mountRef.current.id &&
|
|
330
|
+
!mountRef.current.label
|
|
331
|
+
? {
|
|
332
|
+
"aria-labelledby": `${mountRef.current.id}-label`,
|
|
333
|
+
}
|
|
334
|
+
: {}),
|
|
335
|
+
// Joined, not replaced. `aria-describedby` is the one
|
|
336
|
+
// slot-props key that is a list, and a `Field` above
|
|
337
|
+
// this component has already written its description and
|
|
338
|
+
// its error into it.
|
|
339
|
+
"aria-describedby": [
|
|
340
|
+
mountRef.current.ariaDescribedBy,
|
|
341
|
+
mountRef.current.hintId,
|
|
342
|
+
]
|
|
343
|
+
.filter(Boolean)
|
|
344
|
+
.join(" "),
|
|
345
|
+
...(mountRef.current.id
|
|
346
|
+
? { id: mountRef.current.id }
|
|
347
|
+
: {}),
|
|
348
|
+
}),
|
|
349
|
+
EditorView.updateListener.of((update) => {
|
|
350
|
+
if (update.docChanged) {
|
|
351
|
+
handlersRef.current.onChange?.(update.state.doc.toString());
|
|
352
|
+
}
|
|
353
|
+
}),
|
|
354
|
+
EditorView.domEventHandlers({
|
|
355
|
+
drop: (event, target) => {
|
|
356
|
+
const files = Array.from(event.dataTransfer?.files ?? []).filter(isImageFile);
|
|
357
|
+
if (files.length === 0 ||
|
|
358
|
+
!handlersRef.current.onUploadImage) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
event.preventDefault();
|
|
362
|
+
for (const file of files) {
|
|
363
|
+
uploadCount.current += 1;
|
|
364
|
+
void uploadImage({
|
|
365
|
+
count: uploadCount.current,
|
|
366
|
+
file,
|
|
367
|
+
handlers: handlersRef.current,
|
|
368
|
+
setMessage: setUploadMessage,
|
|
369
|
+
view: target,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return true;
|
|
373
|
+
},
|
|
374
|
+
paste: (event, target) => {
|
|
375
|
+
const files = Array.from(event.clipboardData?.files ?? []).filter(isImageFile);
|
|
376
|
+
if (files.length > 0 &&
|
|
377
|
+
handlersRef.current.onUploadImage) {
|
|
378
|
+
event.preventDefault();
|
|
379
|
+
for (const file of files) {
|
|
380
|
+
uploadCount.current += 1;
|
|
381
|
+
void uploadImage({
|
|
382
|
+
count: uploadCount.current,
|
|
383
|
+
file,
|
|
384
|
+
handlers: handlersRef.current,
|
|
385
|
+
setMessage: setUploadMessage,
|
|
386
|
+
view: target,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
const pasted = event.clipboardData?.getData("text/plain") ?? "";
|
|
392
|
+
const selection = readSelection(target);
|
|
393
|
+
if (isLinkPaste(pasted) &&
|
|
394
|
+
selection.selectionStart !==
|
|
395
|
+
selection.selectionEnd) {
|
|
396
|
+
event.preventDefault();
|
|
397
|
+
applyEdit(target, wrapSelectionInLink(selection, pasted.trim()));
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
},
|
|
402
|
+
}),
|
|
403
|
+
editabilityRef.current.of([
|
|
404
|
+
EditorView.editable.of(true),
|
|
405
|
+
EditorState.readOnly.of(false),
|
|
406
|
+
]),
|
|
407
|
+
],
|
|
408
|
+
}),
|
|
409
|
+
});
|
|
410
|
+
viewRef.current = view;
|
|
411
|
+
if (mountRef.current.isRawModeDefault) {
|
|
412
|
+
view.dispatch({
|
|
413
|
+
effects: setLivePreviewRawMode.of(true),
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
return () => {
|
|
417
|
+
view.destroy();
|
|
418
|
+
viewRef.current = null;
|
|
419
|
+
};
|
|
420
|
+
}, []);
|
|
421
|
+
// Editability flips through a compartment rather than a rebuild,
|
|
422
|
+
// so toggling `isReadOnly` keeps the undo history and the caret.
|
|
423
|
+
useEffect(() => {
|
|
424
|
+
const view = viewRef.current;
|
|
425
|
+
if (!view) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const isEditable = !isDisabled && !isReadOnly;
|
|
429
|
+
view.dispatch({
|
|
430
|
+
effects: editabilityRef.current.reconfigure([
|
|
431
|
+
EditorView.editable.of(isEditable),
|
|
432
|
+
EditorState.readOnly.of(!isEditable),
|
|
433
|
+
]),
|
|
434
|
+
});
|
|
435
|
+
}, [isDisabled, isReadOnly]);
|
|
436
|
+
useEffect(() => {
|
|
437
|
+
viewRef.current?.dispatch({
|
|
438
|
+
effects: setLivePreviewRawMode.of(isRawMode),
|
|
439
|
+
});
|
|
440
|
+
}, [isRawMode]);
|
|
441
|
+
return (_jsxs("div", { className: toClassName(
|
|
442
|
+
// `@container` here rather than on a wrapper: a container
|
|
443
|
+
// query matches a container's *descendants*, never the
|
|
444
|
+
// container itself.
|
|
445
|
+
"@container flex flex-col gap-2 rounded-md border border-border-default bg-surface-base text-content-primary focus-within:outline-solid focus-within:outline-(length:--focus-ring-width) focus-within:outline-offset-(--focus-ring-offset) focus-within:outline-focus-ring",
|
|
446
|
+
// A token pair, never `opacity-*` — fading the whole box
|
|
447
|
+
// fades the hint under it too, and axe measures the
|
|
448
|
+
// *composited* colour.
|
|
449
|
+
isDisabled &&
|
|
450
|
+
"border-border-subtle bg-surface-sunken", className), children: [_jsx("div", { className: "border-border-subtle border-b px-2 pt-2 pb-1", children: _jsx(Toolbar, { items: [
|
|
451
|
+
{
|
|
452
|
+
icon: icons?.bold,
|
|
453
|
+
isDisabled: isDisabled || isReadOnly,
|
|
454
|
+
key: "bold",
|
|
455
|
+
label: "Bold",
|
|
456
|
+
onSelect: () => {
|
|
457
|
+
runCommand((state) => toggleInlineMarker(state, "**"));
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
icon: icons?.italic,
|
|
462
|
+
isDisabled: isDisabled || isReadOnly,
|
|
463
|
+
key: "italic",
|
|
464
|
+
label: "Italic",
|
|
465
|
+
onSelect: () => {
|
|
466
|
+
runCommand((state) => toggleInlineMarker(state, "_"));
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
icon: icons?.heading,
|
|
471
|
+
isDisabled: isDisabled || isReadOnly,
|
|
472
|
+
key: "heading",
|
|
473
|
+
label: "Heading",
|
|
474
|
+
onSelect: () => {
|
|
475
|
+
runCommand((state) => toggleHeading(state, 2));
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
icon: icons?.bulletedList,
|
|
480
|
+
isDisabled: isDisabled || isReadOnly,
|
|
481
|
+
key: "bulleted-list",
|
|
482
|
+
label: "Bulleted list",
|
|
483
|
+
onSelect: () => {
|
|
484
|
+
runCommand((state) => toggleLinePrefix(state, MARKDOWN_LINE_PREFIXES.bulletList));
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
icon: icons?.taskList,
|
|
489
|
+
isDisabled: isDisabled || isReadOnly,
|
|
490
|
+
key: "task-list",
|
|
491
|
+
label: "Task list",
|
|
492
|
+
onSelect: () => {
|
|
493
|
+
runCommand((state) => toggleLinePrefix(state, MARKDOWN_LINE_PREFIXES.taskList));
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
icon: icons?.numberedList,
|
|
498
|
+
isDisabled: isDisabled || isReadOnly,
|
|
499
|
+
key: "numbered-list",
|
|
500
|
+
label: "Numbered list",
|
|
501
|
+
onSelect: () => {
|
|
502
|
+
runCommand((state) => toggleLinePrefix(state, MARKDOWN_LINE_PREFIXES.orderedList));
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
icon: icons?.quote,
|
|
507
|
+
isDisabled: isDisabled || isReadOnly,
|
|
508
|
+
key: "quote",
|
|
509
|
+
label: "Quote",
|
|
510
|
+
onSelect: () => {
|
|
511
|
+
runCommand((state) => toggleLinePrefix(state, MARKDOWN_LINE_PREFIXES.blockquote));
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
icon: icons?.code,
|
|
516
|
+
isDisabled: isDisabled || isReadOnly,
|
|
517
|
+
key: "code",
|
|
518
|
+
label: "Code",
|
|
519
|
+
onSelect: () => {
|
|
520
|
+
runCommand((state) => toggleInlineMarker(state, "`"));
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
icon: icons?.link,
|
|
525
|
+
isDisabled: isDisabled || isReadOnly,
|
|
526
|
+
key: "link",
|
|
527
|
+
label: "Link",
|
|
528
|
+
onSelect: () => {
|
|
529
|
+
runCommand((state) => insertLink(state));
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
/**
|
|
534
|
+
* The "edit Markdown" toggle, as a `Switch` and not a
|
|
535
|
+
* toolbar action — because it is state, not a verb.
|
|
536
|
+
* A `ToolbarAction` renders a `Button`, which
|
|
537
|
+
* announces nothing about being on.
|
|
538
|
+
*/
|
|
539
|
+
element: (_jsx(Switch, { isChecked: isRawMode, isDisabled: isDisabled, label: rawModeLabel, onChange: setIsRawMode, size: "sm" })),
|
|
540
|
+
key: "raw-mode",
|
|
541
|
+
type: "control",
|
|
542
|
+
},
|
|
543
|
+
], label: toolbarLabel, overflow: "panel" }) }), _jsx("div", { className: "min-h-32 px-1 text-md cq-md:min-h-48", ref: hostRef }), _jsxs("div", { className: "flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 px-3 pb-2", children: [_jsx("p", { className: "sr-only text-content-secondary text-sm cq-sm:not-sr-only", id: hintId, children: "Markdown. Ctrl+B bold, Ctrl+I italic, Ctrl+K link, Ctrl+E code." }), _jsx("span", { "aria-label": "Image upload", className: "text-content-secondary text-sm", role: "status", children: uploadMessage })] })] }));
|
|
544
|
+
};
|
|
545
|
+
//# sourceMappingURL=MarkdownEditorCodeMirror.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownEditorCodeMirror.js","sourceRoot":"","sources":["../../src/markdownEditorCodeMirror/MarkdownEditorCodeMirror.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EACL,aAAa,EACb,OAAO,EACP,aAAa,GACd,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,QAAQ,EACR,gBAAgB,GACjB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,UAAU,EACV,MAAM,EACN,WAAW,IAAI,oBAAoB,GACpC,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAOnD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAsB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAwB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EACL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ACD;4BACE;;;;;+BAKG;4BACH,OAAO,EAAE,CACP,KAAC,MAAM,IACL,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAC,IAAI,GACT,CACH;4BACD,GAAG,EAAE,UAAU;4BACf,IAAI,EAAE,SAAS;yBAChB;qBACF,EACD,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAC,OAAO,GAChB,GACE,EAEN,cACE,SAAS,EAAC,sCAAsC,EAChD,GAAG,EAAE,OAAO,GACZ,EAEF,eAAK,SAAS,EAAC,yEAAyE,aAOtF,YACE,SAAS,EAAC,0DAA0D,EACpE,EAAE,EAAE,MAAM,gFAIR,EAEJ,6BACa,cAAc,EACzB,SAAS,EAAC,gCAAgC,EAC1C,IAAI,EAAC,QAAQ,YAEZ,aAAa,GACT,IACH,IACF,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@charcuterie/ui/markdown-editor-codemirror` — the opt-in live
|
|
3
|
+
* preview surface.
|
|
4
|
+
*
|
|
5
|
+
* Its own entry point, and every CodeMirror package it needs is an
|
|
6
|
+
* **optional** peer, so a consumer that never imports this subpath
|
|
7
|
+
* installs none of it and bundles none of it. Same packaging as
|
|
8
|
+
* `@charcuterie/ui/react-router`, and the same reason: the capacity
|
|
9
|
+
* is worth having and is not worth charging everybody for.
|
|
10
|
+
*/
|
|
11
|
+
export { livePreview, livePreviewRawModeField, setLivePreviewRawMode, } from "./livePreview.ts";
|
|
12
|
+
export type { LivePreviewLineKind, LivePreviewMarkKind, LivePreviewRange, LivePreviewSelection, ToLivePreviewRangesOptions, } from "./livePreviewRanges.ts";
|
|
13
|
+
export { toLivePreviewRanges } from "./livePreviewRanges.ts";
|
|
14
|
+
export type { MarkdownEditorCodeMirrorProps } from "./MarkdownEditorCodeMirror.tsx";
|
|
15
|
+
export { MarkdownEditorCodeMirror } from "./MarkdownEditorCodeMirror.tsx";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markdownEditorCodeMirror/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,YAAY,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAA;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@charcuterie/ui/markdown-editor-codemirror` — the opt-in live
|
|
3
|
+
* preview surface.
|
|
4
|
+
*
|
|
5
|
+
* Its own entry point, and every CodeMirror package it needs is an
|
|
6
|
+
* **optional** peer, so a consumer that never imports this subpath
|
|
7
|
+
* installs none of it and bundles none of it. Same packaging as
|
|
8
|
+
* `@charcuterie/ui/react-router`, and the same reason: the capacity
|
|
9
|
+
* is worth having and is not worth charging everybody for.
|
|
10
|
+
*/
|
|
11
|
+
export { livePreview, livePreviewRawModeField, setLivePreviewRawMode, } from "./livePreview.js";
|
|
12
|
+
export { toLivePreviewRanges } from "./livePreviewRanges.js";
|
|
13
|
+
export { MarkdownEditorCodeMirror } from "./MarkdownEditorCodeMirror.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/markdownEditorCodeMirror/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kBAAkB,CAAA;AAQzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAAgC,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CodeMirror half of live preview: descriptors → decorations,
|
|
3
|
+
* two widgets, and a theme that reads Charcuterie tokens.
|
|
4
|
+
*
|
|
5
|
+
* `livePreviewRanges.ts` decided *what* to decorate and is pure.
|
|
6
|
+
* This file owns everything that needs `@codemirror/view`, which is
|
|
7
|
+
* also everything that cannot be tested in this package's Node-only
|
|
8
|
+
* Vitest project — so it is kept deliberately thin and mechanical.
|
|
9
|
+
*
|
|
10
|
+
* ### Why the theme uses `var(--color-…)` and not Tailwind classes
|
|
11
|
+
*
|
|
12
|
+
* Every other visual in this package is a Tailwind utility reading
|
|
13
|
+
* a token. CodeMirror is the exception, and for a structural
|
|
14
|
+
* reason: it generates its own scoped class names and injects its
|
|
15
|
+
* own stylesheet, so the DOM these decorations land on is not DOM
|
|
16
|
+
* Tailwind ever scans. Referencing the custom properties directly
|
|
17
|
+
* keeps a scheme flip a repaint — the same behaviour, one layer
|
|
18
|
+
* lower — and avoids a `safelist` that would rot the first time a
|
|
19
|
+
* class here changed.
|
|
20
|
+
*
|
|
21
|
+
* The properties below are the generated token names, not invented
|
|
22
|
+
* ones. That distinction has already cost this fleet a release:
|
|
23
|
+
* Docket shipped invisible priority bars from `--color-danger-9`, a
|
|
24
|
+
* scale that does not exist, and nothing errored. A custom property
|
|
25
|
+
* that resolves to nothing paints nothing, silently.
|
|
26
|
+
*/
|
|
27
|
+
import type { Extension } from "@codemirror/state";
|
|
28
|
+
import { StateField } from "@codemirror/state";
|
|
29
|
+
/** Toggle the "edit Markdown" mode. */
|
|
30
|
+
export declare const setLivePreviewRawMode: import("@codemirror/state").StateEffectType<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Raw mode as editor state rather than a React prop threaded down.
|
|
33
|
+
*
|
|
34
|
+
* It has to live here because the decoration plugin reads it on
|
|
35
|
+
* every update, and because a keybinding should be able to flip it
|
|
36
|
+
* without a round trip through React.
|
|
37
|
+
*/
|
|
38
|
+
export declare const livePreviewRawModeField: StateField<boolean>;
|
|
39
|
+
export declare const livePreview: () => Extension;
|
|
40
|
+
//# sourceMappingURL=livePreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"livePreview.d.ts","sourceRoot":"","sources":["../../src/markdownEditorCodeMirror/livePreview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAqB3D,uCAAuC;AACvC,eAAO,MAAM,qBAAqB,sDACH,CAAA;AAE/B;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,qBAchC,CAAA;AAqcJ,eAAO,MAAM,WAAW,QAAO,SAM9B,CAAA"}
|