panelui-native 0.46.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/lib/module/components/accordion/index.js +32 -4
- package/lib/module/components/accordion/index.js.map +1 -1
- package/lib/module/components/button/index.js +83 -15
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/button-group/index.js +186 -0
- package/lib/module/components/button-group/index.js.map +1 -0
- package/lib/module/components/color-picker/index.js +110 -1
- package/lib/module/components/color-picker/index.js.map +1 -1
- package/lib/module/components/date-time-picker/index.js +23 -5
- package/lib/module/components/date-time-picker/index.js.map +1 -1
- package/lib/module/components/fab/index.js +514 -0
- package/lib/module/components/fab/index.js.map +1 -0
- package/lib/module/components/markdown-editor/index.js +406 -0
- package/lib/module/components/markdown-editor/index.js.map +1 -0
- package/lib/module/components/markdown-editor/markdown-transforms.js +243 -0
- package/lib/module/components/markdown-editor/markdown-transforms.js.map +1 -0
- package/lib/module/components/questionnaire/index.js +1312 -0
- package/lib/module/components/questionnaire/index.js.map +1 -0
- package/lib/module/components/tabs/index.js +94 -18
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/components/time-picker/index.js +34 -6
- package/lib/module/components/time-picker/index.js.map +1 -1
- package/lib/module/components/tree/index.js +500 -0
- package/lib/module/components/tree/index.js.map +1 -0
- package/lib/module/icons/index.js +217 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +6 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/accordion/index.d.ts +21 -0
- package/lib/typescript/src/components/accordion/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +21 -0
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button-group/index.d.ts +212 -0
- package/lib/typescript/src/components/button-group/index.d.ts.map +1 -0
- package/lib/typescript/src/components/color-picker/index.d.ts +82 -1
- package/lib/typescript/src/components/color-picker/index.d.ts.map +1 -1
- package/lib/typescript/src/components/date-time-picker/index.d.ts +7 -1
- package/lib/typescript/src/components/date-time-picker/index.d.ts.map +1 -1
- package/lib/typescript/src/components/fab/index.d.ts +285 -0
- package/lib/typescript/src/components/fab/index.d.ts.map +1 -0
- package/lib/typescript/src/components/markdown-editor/index.d.ts +102 -0
- package/lib/typescript/src/components/markdown-editor/index.d.ts.map +1 -0
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts +76 -0
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts.map +1 -0
- package/lib/typescript/src/components/questionnaire/index.d.ts +336 -0
- package/lib/typescript/src/components/questionnaire/index.d.ts.map +1 -0
- package/lib/typescript/src/components/tabs/index.d.ts +9 -0
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/components/time-picker/index.d.ts +19 -1
- package/lib/typescript/src/components/time-picker/index.d.ts.map +1 -1
- package/lib/typescript/src/components/tree/index.d.ts +125 -0
- package/lib/typescript/src/components/tree/index.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +22 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +8 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/index.tsx +48 -6
- package/src/components/button/index.tsx +97 -15
- package/src/components/button-group/index.tsx +199 -0
- package/src/components/color-picker/index.tsx +140 -3
- package/src/components/date-time-picker/index.tsx +39 -3
- package/src/components/fab/index.tsx +583 -0
- package/src/components/markdown-editor/index.tsx +526 -0
- package/src/components/markdown-editor/markdown-transforms.ts +228 -0
- package/src/components/questionnaire/index.tsx +1615 -0
- package/src/components/tabs/index.tsx +100 -28
- package/src/components/time-picker/index.tsx +42 -6
- package/src/components/tree/index.tsx +564 -0
- package/src/icons/index.tsx +154 -0
- package/src/index.ts +77 -1
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MarkdownEditor — a field for writing markdown, and a way to see it rendered.
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const [draft, setDraft] = useState('');
|
|
8
|
+
*
|
|
9
|
+
* <MarkdownEditor value={draft} onValueChange={setDraft} rows={12} />
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* ## Writing and reading are two modes, not two panes
|
|
13
|
+
*
|
|
14
|
+
* Side by side is how this is done on a desktop, and it does not survive the
|
|
15
|
+
* trip to a phone: two columns of a phone's width are two columns too narrow to
|
|
16
|
+
* read, and the keyboard covers the bottom half of the screen exactly when the
|
|
17
|
+
* writer is using it. So there is one pane and a switch — write, or read what
|
|
18
|
+
* you wrote. The toolbar carries the switch, because the toolbar is the one
|
|
19
|
+
* thing on screen in both modes.
|
|
20
|
+
*
|
|
21
|
+
* ## The toolbar edits the selection
|
|
22
|
+
*
|
|
23
|
+
* Every button here is a function of the text and where the caret is in it, and
|
|
24
|
+
* the answer that matters is not which characters get inserted but where the
|
|
25
|
+
* caret lands afterwards. Bolding a selected phrase leaves it selected, so it
|
|
26
|
+
* can be italicised next; bolding nothing puts the caret between the new
|
|
27
|
+
* markers, where the writing is about to go; and pressing the same button again
|
|
28
|
+
* takes the markers off. Those rules live in `markdown-transforms.ts` as pure
|
|
29
|
+
* functions over `(text, selection)`, away from anything to do with a field.
|
|
30
|
+
*
|
|
31
|
+
* ## Why it renders through Response
|
|
32
|
+
*
|
|
33
|
+
* The preview is `Response`, the same reader that renders a model's answer, so
|
|
34
|
+
* markdown means the same thing everywhere in the library and there is one
|
|
35
|
+
* parser to be right rather than two to keep in step. It renders through
|
|
36
|
+
* `Typography`, `CodeBlock` and `Table`, which is to say through the app's own
|
|
37
|
+
* type and colours — a preview that looked like a document viewer would be
|
|
38
|
+
* showing the writer something they are not going to ship.
|
|
39
|
+
*
|
|
40
|
+
* Nothing here reaches for a platform markdown renderer. `Text` in SwiftUI can
|
|
41
|
+
* parse markdown and Jetpack Compose's cannot, so a platform-backed editor
|
|
42
|
+
* would render on one of the two and be a plain string on the other.
|
|
43
|
+
*
|
|
44
|
+
* Works controlled (`value` + `onValueChange`) or uncontrolled (`defaultValue`).
|
|
45
|
+
*/
|
|
46
|
+
import { createContext, forwardRef, useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
47
|
+
import { View } from 'react-native';
|
|
48
|
+
import { tv } from 'tailwind-variants';
|
|
49
|
+
import { BoldIcon, CodeIcon, EyeIcon, HeadingIcon, ItalicIcon, LinkIcon, ListIcon, ListOrderedIcon, PencilIcon, QuoteIcon } from "../../icons/index.js";
|
|
50
|
+
import { Text } from "../../primitives/text.js";
|
|
51
|
+
import { cn } from "../../utils/cn.js";
|
|
52
|
+
import { Button } from "../button/index.js";
|
|
53
|
+
import { ButtonGroup } from "../button-group/index.js";
|
|
54
|
+
import { Response } from "../response/index.js";
|
|
55
|
+
import { Textarea } from "../textarea/index.js";
|
|
56
|
+
import { insertLink, toggleFence, toggleLinePrefix, toggleOrderedList, toggleWrap } from "./markdown-transforms.js";
|
|
57
|
+
|
|
58
|
+
/** Which pane the editor is showing. */
|
|
59
|
+
|
|
60
|
+
/** A formatting action the toolbar can offer. */
|
|
61
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
62
|
+
/** The actions a toolbar shows when it is not told which to show. */
|
|
63
|
+
const DEFAULT_ACTIONS = ['bold', 'italic', 'heading', 'bulletList', 'orderedList', 'quote', 'code', 'link'];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* What each action does, what it is called, and what it looks like.
|
|
67
|
+
*
|
|
68
|
+
* One table rather than a switch in the toolbar and another in the context:
|
|
69
|
+
* adding an action should be adding a row here, and nowhere else.
|
|
70
|
+
*/
|
|
71
|
+
const ACTIONS = {
|
|
72
|
+
bold: {
|
|
73
|
+
label: 'Bold',
|
|
74
|
+
icon: size => /*#__PURE__*/_jsx(BoldIcon, {
|
|
75
|
+
size: size
|
|
76
|
+
}),
|
|
77
|
+
apply: (text, selection) => toggleWrap(text, selection, '**')
|
|
78
|
+
},
|
|
79
|
+
italic: {
|
|
80
|
+
label: 'Italic',
|
|
81
|
+
icon: size => /*#__PURE__*/_jsx(ItalicIcon, {
|
|
82
|
+
size: size
|
|
83
|
+
}),
|
|
84
|
+
apply: (text, selection) => toggleWrap(text, selection, '_')
|
|
85
|
+
},
|
|
86
|
+
heading: {
|
|
87
|
+
label: 'Heading',
|
|
88
|
+
icon: size => /*#__PURE__*/_jsx(HeadingIcon, {
|
|
89
|
+
size: size
|
|
90
|
+
}),
|
|
91
|
+
apply: (text, selection) => toggleLinePrefix(text, selection, '## ')
|
|
92
|
+
},
|
|
93
|
+
quote: {
|
|
94
|
+
label: 'Quote',
|
|
95
|
+
icon: size => /*#__PURE__*/_jsx(QuoteIcon, {
|
|
96
|
+
size: size
|
|
97
|
+
}),
|
|
98
|
+
apply: (text, selection) => toggleLinePrefix(text, selection, '> ')
|
|
99
|
+
},
|
|
100
|
+
code: {
|
|
101
|
+
label: 'Code block',
|
|
102
|
+
icon: size => /*#__PURE__*/_jsx(CodeIcon, {
|
|
103
|
+
size: size
|
|
104
|
+
}),
|
|
105
|
+
apply: toggleFence
|
|
106
|
+
},
|
|
107
|
+
bulletList: {
|
|
108
|
+
label: 'Bulleted list',
|
|
109
|
+
icon: size => /*#__PURE__*/_jsx(ListIcon, {
|
|
110
|
+
size: size
|
|
111
|
+
}),
|
|
112
|
+
apply: (text, selection) => toggleLinePrefix(text, selection, '- ')
|
|
113
|
+
},
|
|
114
|
+
orderedList: {
|
|
115
|
+
label: 'Numbered list',
|
|
116
|
+
icon: size => /*#__PURE__*/_jsx(ListOrderedIcon, {
|
|
117
|
+
size: size
|
|
118
|
+
}),
|
|
119
|
+
apply: toggleOrderedList
|
|
120
|
+
},
|
|
121
|
+
link: {
|
|
122
|
+
label: 'Link',
|
|
123
|
+
icon: size => /*#__PURE__*/_jsx(LinkIcon, {
|
|
124
|
+
size: size
|
|
125
|
+
}),
|
|
126
|
+
apply: insertLink
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const markdownEditorVariants = tv({
|
|
130
|
+
slots: {
|
|
131
|
+
root: 'w-full gap-2',
|
|
132
|
+
toolbar: 'flex-row items-center justify-between gap-2',
|
|
133
|
+
// The preview stands in the field's place, so it takes the field's shape.
|
|
134
|
+
// A rendered draft that sat on the page with no edge around it would not
|
|
135
|
+
// read as the same object the writing was in.
|
|
136
|
+
preview: 'w-full rounded-xl border border-input bg-popover px-3 py-2.5',
|
|
137
|
+
empty: 'py-6 text-center'
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const MarkdownEditorContext = /*#__PURE__*/createContext(null);
|
|
141
|
+
function useMarkdownEditor(part) {
|
|
142
|
+
const ctx = useContext(MarkdownEditorContext);
|
|
143
|
+
if (!ctx) throw new Error(`${part} must be used inside <MarkdownEditor>.`);
|
|
144
|
+
return ctx;
|
|
145
|
+
}
|
|
146
|
+
const MarkdownEditorRoot = /*#__PURE__*/forwardRef(({
|
|
147
|
+
className,
|
|
148
|
+
value: valueProp,
|
|
149
|
+
defaultValue = '',
|
|
150
|
+
onValueChange,
|
|
151
|
+
mode: modeProp,
|
|
152
|
+
defaultMode = 'write',
|
|
153
|
+
onModeChange,
|
|
154
|
+
disabled = false,
|
|
155
|
+
children,
|
|
156
|
+
placeholder,
|
|
157
|
+
rows,
|
|
158
|
+
...props
|
|
159
|
+
}, ref) => {
|
|
160
|
+
const slots = markdownEditorVariants();
|
|
161
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
162
|
+
const value = valueProp ?? internalValue;
|
|
163
|
+
const [internalMode, setInternalMode] = useState(defaultMode);
|
|
164
|
+
const mode = modeProp ?? internalMode;
|
|
165
|
+
|
|
166
|
+
/*
|
|
167
|
+
* The live selection is a ref rather than state.
|
|
168
|
+
*
|
|
169
|
+
* It changes on every caret move — every keystroke, every tap in the text —
|
|
170
|
+
* and nothing on screen depends on it. Holding it in state would re-render
|
|
171
|
+
* the field, and therefore the preview under it, once per character typed.
|
|
172
|
+
*/
|
|
173
|
+
const selectionRef = useRef({
|
|
174
|
+
start: 0,
|
|
175
|
+
end: 0
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/*
|
|
179
|
+
* What the field should show as selected after a toolbar edit, held for
|
|
180
|
+
* exactly one render.
|
|
181
|
+
*
|
|
182
|
+
* A `selection` prop that stays set is a field the writer cannot move the
|
|
183
|
+
* caret in — every tap would be pulled back to wherever the last edit put
|
|
184
|
+
* it. So it is set once, applied, and cleared by the very selection change
|
|
185
|
+
* it causes.
|
|
186
|
+
*/
|
|
187
|
+
const [pending, setPending] = useState(undefined);
|
|
188
|
+
const valueRef = useRef(value);
|
|
189
|
+
valueRef.current = value;
|
|
190
|
+
const commit = useCallback(next => {
|
|
191
|
+
if (valueProp === undefined) setInternalValue(next);
|
|
192
|
+
onValueChange?.(next);
|
|
193
|
+
}, [valueProp, onValueChange]);
|
|
194
|
+
const setMode = useCallback(next => {
|
|
195
|
+
if (modeProp === undefined) setInternalMode(next);
|
|
196
|
+
onModeChange?.(next);
|
|
197
|
+
}, [modeProp, onModeChange]);
|
|
198
|
+
const run = useCallback(action => {
|
|
199
|
+
const result = ACTIONS[action].apply(valueRef.current, selectionRef.current);
|
|
200
|
+
// Kept locally too: the parent may be slow to hand the new text back,
|
|
201
|
+
// and the next press must not be computed against the old string.
|
|
202
|
+
valueRef.current = result.text;
|
|
203
|
+
selectionRef.current = result.selection;
|
|
204
|
+
commit(result.text);
|
|
205
|
+
setPending(result.selection);
|
|
206
|
+
}, [commit]);
|
|
207
|
+
const context = useMemo(() => ({
|
|
208
|
+
value,
|
|
209
|
+
mode,
|
|
210
|
+
setMode,
|
|
211
|
+
run,
|
|
212
|
+
pending,
|
|
213
|
+
setSelection: selection => {
|
|
214
|
+
selectionRef.current = selection;
|
|
215
|
+
},
|
|
216
|
+
clearPending: () => setPending(undefined),
|
|
217
|
+
onChangeText: next => {
|
|
218
|
+
valueRef.current = next;
|
|
219
|
+
commit(next);
|
|
220
|
+
},
|
|
221
|
+
disabled
|
|
222
|
+
}), [value, mode, setMode, run, pending, commit, disabled]);
|
|
223
|
+
return /*#__PURE__*/_jsx(MarkdownEditorContext.Provider, {
|
|
224
|
+
value: context,
|
|
225
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
226
|
+
ref: ref,
|
|
227
|
+
className: slots.root({
|
|
228
|
+
className
|
|
229
|
+
}),
|
|
230
|
+
...props,
|
|
231
|
+
children: children ?? /*#__PURE__*/_jsxs(_Fragment, {
|
|
232
|
+
children: [/*#__PURE__*/_jsx(MarkdownEditorToolbar, {}), /*#__PURE__*/_jsx(MarkdownEditorInput, {
|
|
233
|
+
placeholder: placeholder,
|
|
234
|
+
rows: rows
|
|
235
|
+
}), /*#__PURE__*/_jsx(MarkdownEditorPreview, {})]
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
MarkdownEditorRoot.displayName = 'MarkdownEditor';
|
|
241
|
+
|
|
242
|
+
/* -------------------------------------------------------------------------- *
|
|
243
|
+
* Toolbar
|
|
244
|
+
* -------------------------------------------------------------------------- */
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The formatting actions, and the switch between writing and reading.
|
|
248
|
+
*
|
|
249
|
+
* The formatting run is hidden rather than disabled while previewing. Its
|
|
250
|
+
* buttons act on a selection, and in the preview there is no selection for them
|
|
251
|
+
* to act on — a row of controls that are present but inert is a row that has to
|
|
252
|
+
* be tried before it can be understood.
|
|
253
|
+
*/
|
|
254
|
+
const MarkdownEditorToolbar = /*#__PURE__*/forwardRef(({
|
|
255
|
+
className,
|
|
256
|
+
actions = DEFAULT_ACTIONS,
|
|
257
|
+
showModeSwitch = true,
|
|
258
|
+
children,
|
|
259
|
+
...props
|
|
260
|
+
}, ref) => {
|
|
261
|
+
const {
|
|
262
|
+
mode,
|
|
263
|
+
setMode,
|
|
264
|
+
run,
|
|
265
|
+
disabled
|
|
266
|
+
} = useMarkdownEditor('MarkdownEditor.Toolbar');
|
|
267
|
+
const slots = markdownEditorVariants();
|
|
268
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
269
|
+
ref: ref,
|
|
270
|
+
className: slots.toolbar({
|
|
271
|
+
className
|
|
272
|
+
}),
|
|
273
|
+
...props,
|
|
274
|
+
children: [mode === 'write' ? /*#__PURE__*/_jsx(ButtonGroup, {
|
|
275
|
+
variant: "ghost",
|
|
276
|
+
size: "sm",
|
|
277
|
+
className: "shrink",
|
|
278
|
+
children: actions.map(action => /*#__PURE__*/_jsx(Button, {
|
|
279
|
+
accessibilityLabel: ACTIONS[action].label,
|
|
280
|
+
disabled: disabled,
|
|
281
|
+
onPress: () => run(action),
|
|
282
|
+
className: "px-2",
|
|
283
|
+
children: ACTIONS[action].icon(16)
|
|
284
|
+
}, action))
|
|
285
|
+
}) : /*#__PURE__*/_jsx(View, {
|
|
286
|
+
className: "shrink"
|
|
287
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
288
|
+
className: "flex-row items-center gap-2",
|
|
289
|
+
children: [children, showModeSwitch ? /*#__PURE__*/_jsxs(ButtonGroup, {
|
|
290
|
+
size: "sm",
|
|
291
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
292
|
+
variant: mode === 'write' ? 'secondary' : 'ghost',
|
|
293
|
+
startContent: /*#__PURE__*/_jsx(PencilIcon, {
|
|
294
|
+
size: 14
|
|
295
|
+
}),
|
|
296
|
+
onPress: () => setMode('write'),
|
|
297
|
+
children: "Write"
|
|
298
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
299
|
+
variant: mode === 'preview' ? 'secondary' : 'ghost',
|
|
300
|
+
startContent: /*#__PURE__*/_jsx(EyeIcon, {
|
|
301
|
+
size: 14
|
|
302
|
+
}),
|
|
303
|
+
onPress: () => setMode('preview'),
|
|
304
|
+
children: "Preview"
|
|
305
|
+
})]
|
|
306
|
+
}) : null]
|
|
307
|
+
})]
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
MarkdownEditorToolbar.displayName = 'MarkdownEditor.Toolbar';
|
|
311
|
+
|
|
312
|
+
/* -------------------------------------------------------------------------- *
|
|
313
|
+
* Input
|
|
314
|
+
* -------------------------------------------------------------------------- */
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The field the markdown is written in — a `Textarea`, tracking its selection.
|
|
318
|
+
*
|
|
319
|
+
* Renders nothing while the preview is up. Unmounted rather than hidden: a
|
|
320
|
+
* field kept alive behind the preview keeps the keyboard up with it.
|
|
321
|
+
*/
|
|
322
|
+
const MarkdownEditorInput = /*#__PURE__*/forwardRef(({
|
|
323
|
+
className,
|
|
324
|
+
rows = 8,
|
|
325
|
+
...props
|
|
326
|
+
}, ref) => {
|
|
327
|
+
const {
|
|
328
|
+
value,
|
|
329
|
+
mode,
|
|
330
|
+
pending,
|
|
331
|
+
setSelection,
|
|
332
|
+
clearPending,
|
|
333
|
+
onChangeText,
|
|
334
|
+
disabled
|
|
335
|
+
} = useMarkdownEditor('MarkdownEditor.Input');
|
|
336
|
+
const handleSelectionChange = useCallback(event => {
|
|
337
|
+
setSelection(event.nativeEvent.selection);
|
|
338
|
+
// The edit's own selection has now landed, so stop forcing it and give
|
|
339
|
+
// the caret back to whoever is holding the phone.
|
|
340
|
+
clearPending();
|
|
341
|
+
}, [setSelection, clearPending]);
|
|
342
|
+
if (mode !== 'write') return null;
|
|
343
|
+
return /*#__PURE__*/_jsx(Textarea, {
|
|
344
|
+
ref: ref,
|
|
345
|
+
value: value,
|
|
346
|
+
onChangeText: onChangeText,
|
|
347
|
+
selection: pending,
|
|
348
|
+
onSelectionChange: handleSelectionChange,
|
|
349
|
+
disabled: disabled,
|
|
350
|
+
rows: rows,
|
|
351
|
+
autoCapitalize: "none",
|
|
352
|
+
autoCorrect: false
|
|
353
|
+
// A markdown source is code as much as it is prose: an editor that
|
|
354
|
+
// capitalises the word after a fence, or rewrites a dash into an
|
|
355
|
+
// en dash, is an editor that changes what the document renders as.
|
|
356
|
+
,
|
|
357
|
+
className: cn('font-mono', className),
|
|
358
|
+
...props
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
MarkdownEditorInput.displayName = 'MarkdownEditor.Input';
|
|
362
|
+
|
|
363
|
+
/* -------------------------------------------------------------------------- *
|
|
364
|
+
* Preview
|
|
365
|
+
* -------------------------------------------------------------------------- */
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The draft, rendered.
|
|
369
|
+
*
|
|
370
|
+
* Renders nothing while the field is up, which is what makes the two one pane
|
|
371
|
+
* rather than two.
|
|
372
|
+
*/
|
|
373
|
+
const MarkdownEditorPreview = /*#__PURE__*/forwardRef(({
|
|
374
|
+
className,
|
|
375
|
+
emptyText = 'Nothing to preview yet.',
|
|
376
|
+
...props
|
|
377
|
+
}, ref) => {
|
|
378
|
+
const {
|
|
379
|
+
value,
|
|
380
|
+
mode
|
|
381
|
+
} = useMarkdownEditor('MarkdownEditor.Preview');
|
|
382
|
+
const slots = markdownEditorVariants();
|
|
383
|
+
if (mode !== 'preview') return null;
|
|
384
|
+
return /*#__PURE__*/_jsx(View, {
|
|
385
|
+
ref: ref,
|
|
386
|
+
className: slots.preview({
|
|
387
|
+
className
|
|
388
|
+
}),
|
|
389
|
+
...props,
|
|
390
|
+
children: value.trim() ? /*#__PURE__*/_jsx(Response, {
|
|
391
|
+
children: value
|
|
392
|
+
}) : /*#__PURE__*/_jsx(Text, {
|
|
393
|
+
size: "sm",
|
|
394
|
+
muted: true,
|
|
395
|
+
className: slots.empty(),
|
|
396
|
+
children: emptyText
|
|
397
|
+
})
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
MarkdownEditorPreview.displayName = 'MarkdownEditor.Preview';
|
|
401
|
+
export const MarkdownEditor = Object.assign(MarkdownEditorRoot, {
|
|
402
|
+
Toolbar: MarkdownEditorToolbar,
|
|
403
|
+
Input: MarkdownEditorInput,
|
|
404
|
+
Preview: MarkdownEditorPreview
|
|
405
|
+
});
|
|
406
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","forwardRef","useCallback","useContext","useMemo","useRef","useState","View","tv","BoldIcon","CodeIcon","EyeIcon","HeadingIcon","ItalicIcon","LinkIcon","ListIcon","ListOrderedIcon","PencilIcon","QuoteIcon","Text","cn","Button","ButtonGroup","Response","Textarea","insertLink","toggleFence","toggleLinePrefix","toggleOrderedList","toggleWrap","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DEFAULT_ACTIONS","ACTIONS","bold","label","icon","size","apply","text","selection","italic","heading","quote","code","bulletList","orderedList","link","markdownEditorVariants","slots","root","toolbar","preview","empty","MarkdownEditorContext","useMarkdownEditor","part","ctx","Error","MarkdownEditorRoot","className","value","valueProp","defaultValue","onValueChange","mode","modeProp","defaultMode","onModeChange","disabled","children","placeholder","rows","props","ref","internalValue","setInternalValue","internalMode","setInternalMode","selectionRef","start","end","pending","setPending","undefined","valueRef","current","commit","next","setMode","run","action","result","context","setSelection","clearPending","onChangeText","Provider","MarkdownEditorToolbar","MarkdownEditorInput","MarkdownEditorPreview","displayName","actions","showModeSwitch","variant","map","accessibilityLabel","onPress","startContent","handleSelectionChange","event","nativeEvent","onSelectionChange","autoCapitalize","autoCorrect","emptyText","trim","muted","MarkdownEditor","Object","assign","Toolbar","Input","Preview"],"sourceRoot":"../../../../src","sources":["components/markdown-editor/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAE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E;EAC9D8D,OAAO,EAAEvB,qBAAqB;EAC9BwB,KAAK,EAAEvB,mBAAmB;EAC1BwB,OAAO,EAAEvB;AACX,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The edits a formatting toolbar makes, as functions of the text and where the
|
|
5
|
+
* caret is in it.
|
|
6
|
+
*
|
|
7
|
+
* Pure, and deliberately so. Every one of these takes `(text, selection)` and
|
|
8
|
+
* returns the text that should replace it together with where the selection
|
|
9
|
+
* should end up — no component, no ref, no input. What makes a formatting
|
|
10
|
+
* toolbar feel broken is never the characters it inserts; it is where the caret
|
|
11
|
+
* lands afterwards, and that is a property of these functions rather than of
|
|
12
|
+
* the field they are wired to.
|
|
13
|
+
*
|
|
14
|
+
* Three rules they all keep:
|
|
15
|
+
*
|
|
16
|
+
* - **Applying twice undoes it.** A toolbar button that only ever adds is a
|
|
17
|
+
* button you can press once, and every press after that damages the text.
|
|
18
|
+
* - **A selection stays selected.** Bolding three words and then italicising
|
|
19
|
+
* the same three has to be two presses, not a press and a re-selection.
|
|
20
|
+
* - **With nothing selected, the caret lands where the writing goes** — between
|
|
21
|
+
* the new markers rather than after them.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** Clamps a selection to the text it belongs to, and puts it the right way round. */
|
|
25
|
+
function normalise(text, selection) {
|
|
26
|
+
const a = Math.max(0, Math.min(text.length, selection.start));
|
|
27
|
+
const b = Math.max(0, Math.min(text.length, selection.end));
|
|
28
|
+
return {
|
|
29
|
+
start: Math.min(a, b),
|
|
30
|
+
end: Math.max(a, b)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* -------------------------------------------------------------------------- *
|
|
35
|
+
* Inline markers — bold, italic, inline code
|
|
36
|
+
* -------------------------------------------------------------------------- */
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Wraps the selection in `marker`, or unwraps it if it is already wrapped.
|
|
40
|
+
*
|
|
41
|
+
* "Already wrapped" is checked both ways round: the markers may be inside the
|
|
42
|
+
* selection (the writer selected `**bold**`) or immediately outside it (they
|
|
43
|
+
* selected `bold` in the middle of `**bold**`). Both are the same intent, and a
|
|
44
|
+
* toolbar that only recognised one of them would add a second pair of asterisks
|
|
45
|
+
* to text that already had them.
|
|
46
|
+
*/
|
|
47
|
+
export function toggleWrap(text, selection, marker) {
|
|
48
|
+
const {
|
|
49
|
+
start,
|
|
50
|
+
end
|
|
51
|
+
} = normalise(text, selection);
|
|
52
|
+
const selected = text.slice(start, end);
|
|
53
|
+
const len = marker.length;
|
|
54
|
+
|
|
55
|
+
// The markers are inside the selection.
|
|
56
|
+
if (selected.length >= len * 2 && selected.startsWith(marker) && selected.endsWith(marker)) {
|
|
57
|
+
const inner = selected.slice(len, selected.length - len);
|
|
58
|
+
return {
|
|
59
|
+
text: text.slice(0, start) + inner + text.slice(end),
|
|
60
|
+
selection: {
|
|
61
|
+
start,
|
|
62
|
+
end: start + inner.length
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// The markers are just outside it.
|
|
68
|
+
const before = text.slice(Math.max(0, start - len), start);
|
|
69
|
+
const after = text.slice(end, end + len);
|
|
70
|
+
if (before === marker && after === marker) {
|
|
71
|
+
return {
|
|
72
|
+
text: text.slice(0, start - len) + selected + text.slice(end + len),
|
|
73
|
+
selection: {
|
|
74
|
+
start: start - len,
|
|
75
|
+
end: end - len + selected.length
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const next = text.slice(0, start) + marker + selected + marker + text.slice(end);
|
|
80
|
+
|
|
81
|
+
// Nothing selected: the caret goes between the markers, which is where the
|
|
82
|
+
// writer is about to type. Something selected: it stays selected.
|
|
83
|
+
return selected ? {
|
|
84
|
+
text: next,
|
|
85
|
+
selection: {
|
|
86
|
+
start: start + len,
|
|
87
|
+
end: end + len
|
|
88
|
+
}
|
|
89
|
+
} : {
|
|
90
|
+
text: next,
|
|
91
|
+
selection: {
|
|
92
|
+
start: start + len,
|
|
93
|
+
end: start + len
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* -------------------------------------------------------------------------- *
|
|
99
|
+
* Line prefixes — headings, lists, quotes
|
|
100
|
+
* -------------------------------------------------------------------------- */
|
|
101
|
+
|
|
102
|
+
/** The span of whole lines the selection touches, even partly. */
|
|
103
|
+
function lineRange(text, selection) {
|
|
104
|
+
const {
|
|
105
|
+
start,
|
|
106
|
+
end
|
|
107
|
+
} = normalise(text, selection);
|
|
108
|
+
const from = text.lastIndexOf('\n', start - 1) + 1;
|
|
109
|
+
const lineEnd = text.indexOf('\n', end);
|
|
110
|
+
return {
|
|
111
|
+
start: from,
|
|
112
|
+
end: lineEnd === -1 ? text.length : lineEnd
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Replaces the text between two offsets and reports where the selection goes.
|
|
118
|
+
*
|
|
119
|
+
* The selection is kept over the same *lines* rather than the same character
|
|
120
|
+
* offsets — prefixing four lines moves everything after the first one along,
|
|
121
|
+
* and a selection that did not move with them would end up covering a different
|
|
122
|
+
* four lines than the ones just changed.
|
|
123
|
+
*/
|
|
124
|
+
function replaceBlock(text, range, replacement) {
|
|
125
|
+
return {
|
|
126
|
+
text: text.slice(0, range.start) + replacement + text.slice(range.end),
|
|
127
|
+
selection: {
|
|
128
|
+
start: range.start,
|
|
129
|
+
end: range.start + replacement.length
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Puts `prefix` on the front of every line the selection touches, or takes it
|
|
136
|
+
* off if every one of them already has it.
|
|
137
|
+
*
|
|
138
|
+
* Every one, not any one: a mixed block is a block the writer is trying to make
|
|
139
|
+
* uniform, so the useful answer there is to add rather than to remove.
|
|
140
|
+
*/
|
|
141
|
+
export function toggleLinePrefix(text, selection, prefix) {
|
|
142
|
+
const range = lineRange(text, selection);
|
|
143
|
+
const lines = text.slice(range.start, range.end).split('\n');
|
|
144
|
+
const has = line => line.startsWith(prefix);
|
|
145
|
+
const next = lines.every(has) ? lines.map(line => line.slice(prefix.length)) : lines.map(line => has(line) ? line : prefix + line);
|
|
146
|
+
return replaceBlock(text, range, next.join('\n'));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** How an ordered-list line starts, so it can be recognised and removed. */
|
|
150
|
+
const ORDERED = /^\d+\.\s/;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Numbers the lines the selection touches, or unnumbers them.
|
|
154
|
+
*
|
|
155
|
+
* Counted from one within the block rather than continuing whatever came above
|
|
156
|
+
* it: the numbers a writer types are not the numbers that get rendered — every
|
|
157
|
+
* markdown reader renumbers an ordered list from its first item — so the useful
|
|
158
|
+
* thing is for the source to read the way the output will.
|
|
159
|
+
*/
|
|
160
|
+
export function toggleOrderedList(text, selection) {
|
|
161
|
+
const range = lineRange(text, selection);
|
|
162
|
+
const lines = text.slice(range.start, range.end).split('\n');
|
|
163
|
+
const next = lines.every(line => ORDERED.test(line)) ? lines.map(line => line.replace(ORDERED, '')) : lines.map((line, i) => `${i + 1}. ${line.replace(ORDERED, '')}`);
|
|
164
|
+
return replaceBlock(text, range, next.join('\n'));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* -------------------------------------------------------------------------- *
|
|
168
|
+
* Links
|
|
169
|
+
* -------------------------------------------------------------------------- */
|
|
170
|
+
|
|
171
|
+
/** Placeholder left where a link's target goes. */
|
|
172
|
+
export const LINK_PLACEHOLDER = 'url';
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Turns the selection into a link, and selects the part that still needs
|
|
176
|
+
* filling in.
|
|
177
|
+
*
|
|
178
|
+
* Which part that is depends on what was selected. With text selected, the
|
|
179
|
+
* label is written and the target is not, so the placeholder target is left
|
|
180
|
+
* selected and typing replaces it. With nothing selected there is neither, and
|
|
181
|
+
* the label comes first because it is the half the writer is thinking about.
|
|
182
|
+
*/
|
|
183
|
+
export function insertLink(text, selection) {
|
|
184
|
+
const {
|
|
185
|
+
start,
|
|
186
|
+
end
|
|
187
|
+
} = normalise(text, selection);
|
|
188
|
+
const label = text.slice(start, end);
|
|
189
|
+
const inserted = `[${label}](${LINK_PLACEHOLDER})`;
|
|
190
|
+
const next = text.slice(0, start) + inserted + text.slice(end);
|
|
191
|
+
if (label) {
|
|
192
|
+
const from = start + label.length + 3; // `[` + label + `](`
|
|
193
|
+
return {
|
|
194
|
+
text: next,
|
|
195
|
+
selection: {
|
|
196
|
+
start: from,
|
|
197
|
+
end: from + LINK_PLACEHOLDER.length
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
text: next,
|
|
203
|
+
selection: {
|
|
204
|
+
start: start + 1,
|
|
205
|
+
end: start + 1
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* -------------------------------------------------------------------------- *
|
|
211
|
+
* Fenced code
|
|
212
|
+
* -------------------------------------------------------------------------- */
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Puts the selected lines in a fence, or takes them out of one.
|
|
216
|
+
*
|
|
217
|
+
* A fence is the one construct that has to sit on lines of its own, so this
|
|
218
|
+
* makes room for itself: a blank line before it when it is not already at the
|
|
219
|
+
* start of a paragraph, and one after it at the end.
|
|
220
|
+
*/
|
|
221
|
+
export function toggleFence(text, selection) {
|
|
222
|
+
const range = lineRange(text, selection);
|
|
223
|
+
const block = text.slice(range.start, range.end);
|
|
224
|
+
const lines = block.split('\n');
|
|
225
|
+
if (lines.length >= 2 && lines[0]?.startsWith('```') && lines.at(-1) === '```') {
|
|
226
|
+
return replaceBlock(text, range, lines.slice(1, -1).join('\n'));
|
|
227
|
+
}
|
|
228
|
+
const leadIn = range.start > 0 && text[range.start - 1] !== '\n' ? '\n' : '';
|
|
229
|
+
const fenced = `${leadIn}\`\`\`\n${block}\n\`\`\``;
|
|
230
|
+
const result = replaceBlock(text, range, fenced);
|
|
231
|
+
|
|
232
|
+
// Inside the fence, on the line the code goes on — not around the whole
|
|
233
|
+
// block, which would be selecting the markers along with the content.
|
|
234
|
+
const inner = range.start + leadIn.length + 4;
|
|
235
|
+
return {
|
|
236
|
+
text: result.text,
|
|
237
|
+
selection: {
|
|
238
|
+
start: inner,
|
|
239
|
+
end: inner + block.length
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=markdown-transforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["normalise","text","selection","a","Math","max","min","length","start","b","end","toggleWrap","marker","selected","slice","len","startsWith","endsWith","inner","before","after","next","lineRange","from","lastIndexOf","lineEnd","indexOf","replaceBlock","range","replacement","toggleLinePrefix","prefix","lines","split","has","line","every","map","join","ORDERED","toggleOrderedList","test","replace","i","LINK_PLACEHOLDER","insertLink","label","inserted","toggleFence","block","at","leadIn","fenced","result"],"sourceRoot":"../../../../src","sources":["components/markdown-editor/markdown-transforms.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA,SAASA,SAASA,CAACC,IAAY,EAAEC,SAA0B,EAAmB;EAC5E,MAAMC,CAAC,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAACL,IAAI,CAACM,MAAM,EAAEL,SAAS,CAACM,KAAK,CAAC,CAAC;EAC7D,MAAMC,CAAC,GAAGL,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAACL,IAAI,CAACM,MAAM,EAAEL,SAAS,CAACQ,GAAG,CAAC,CAAC;EAC3D,OAAO;IAAEF,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