@tristan2828/ui-foundation 4.125.0 → 4.127.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 +1 -1
- package/conventions/docs/add-an-entity.md +140 -35
- package/conventions/docs/cell-patterns.md +144 -56
- package/conventions/docs/design-language.md +45 -13
- package/dist/api/contracts.d.ts +8 -1
- package/dist/api/gateway/errors.js +4 -0
- package/dist/api/schema.d.ts +9 -0
- package/dist/api/transport/index.js +10 -1
- package/dist/components/app/data-table-tools.d.ts +12 -0
- package/dist/components/app/data-table-tools.js +2 -2
- package/dist/components/app/data-table.d.ts +2 -1
- package/dist/components/app/data-table.js +1 -1
- package/dist/components/app/edit-caret.d.ts +25 -0
- package/dist/components/app/edit-caret.js +118 -0
- package/dist/components/app/edit-in-place-presets.d.ts +51 -1
- package/dist/components/app/edit-in-place-presets.js +30 -0
- package/dist/components/app/edit-in-place-store.d.ts +70 -4
- package/dist/components/app/edit-in-place-store.js +219 -21
- package/dist/components/app/edit-in-place.d.ts +11 -0
- package/dist/components/app/editable-value.js +202 -25
- package/dist/components/app/entity-form.js +4 -0
- package/dist/components/app/entity-view.js +5 -1
- package/dist/components/app/equal-items.d.ts +32 -6
- package/dist/components/app/equal-items.js +59 -8
- package/dist/components/app/error-state.js +1 -0
- package/dist/components/app/form-leave-guard.js +7 -1
- package/dist/components/app/milkdown-editor.d.ts +1 -0
- package/dist/components/app/milkdown-editor.js +226 -64
- package/dist/components/app/pill-filter.d.ts +16 -0
- package/dist/components/app/pill-filter.js +22 -1
- package/dist/components/app/prose-look.d.ts +1 -1
- package/dist/components/app/prose-look.js +3 -1
- package/dist/components/app/rating-input.d.ts +22 -0
- package/dist/components/app/rating-input.js +65 -0
- package/dist/components/app/rating-score.d.ts +2 -1
- package/dist/components/app/rating-score.js +2 -6
- package/dist/components/app/rich-text-autolink.d.ts +6 -0
- package/dist/components/app/rich-text-autolink.js +79 -0
- package/dist/components/app/rich-text-edges.d.ts +8 -0
- package/dist/components/app/rich-text-edges.js +144 -0
- package/dist/components/app/rich-text-editor.d.ts +19 -4
- package/dist/components/app/rich-text-editor.js +19 -6
- package/dist/components/app/rich-text-empty-paragraph.d.ts +14 -6
- package/dist/components/app/rich-text-empty-paragraph.js +19 -8
- package/dist/components/app/rich-text-formats.js +88 -15
- package/dist/components/app/rich-text-full-screen.d.ts +2 -0
- package/dist/components/app/rich-text-full-screen.js +78 -0
- package/dist/components/app/rich-text-highlight-menu.d.ts +3 -1
- package/dist/components/app/rich-text-highlight-menu.js +3 -2
- package/dist/components/app/rich-text-input-rules.d.ts +7 -0
- package/dist/components/app/rich-text-input-rules.js +83 -0
- package/dist/components/app/rich-text-keyboard-bar.d.ts +24 -0
- package/dist/components/app/rich-text-keyboard-bar.js +215 -0
- package/dist/components/app/rich-text-node-views.js +2 -1
- package/dist/components/app/rich-text-paste.d.ts +43 -0
- package/dist/components/app/rich-text-paste.js +355 -0
- package/dist/components/app/rich-text-shortcuts.d.ts +5 -1
- package/dist/components/app/rich-text-shortcuts.js +132 -2
- package/dist/components/app/rich-text-slash-menu.js +47 -9
- package/dist/components/app/rich-text-slash.d.ts +7 -0
- package/dist/components/app/rich-text-slash.js +27 -14
- package/dist/components/app/rich-text-table-grips.d.ts +8 -6
- package/dist/components/app/rich-text-table-grips.js +11 -12
- package/dist/components/app/rich-text-tasks.d.ts +8 -0
- package/dist/components/app/rich-text-tasks.js +20 -0
- package/dist/components/app/rich-text-toolbar.d.ts +5 -1
- package/dist/components/app/rich-text-toolbar.js +14 -6
- package/dist/components/app/rich-text-tools-bar.d.ts +3 -1
- package/dist/components/app/rich-text-tools-bar.js +2 -2
- package/dist/components/app/rich-text-touch.d.ts +2 -0
- package/dist/components/app/rich-text-touch.js +18 -0
- package/dist/components/app/rich-text-widgets.js +1 -1
- package/dist/hooks/table-url-changes.d.ts +4 -0
- package/dist/hooks/table-url-changes.js +13 -0
- package/dist/hooks/use-record-update.d.ts +13 -1
- package/dist/hooks/use-record-update.js +17 -3
- package/dist/hooks/use-table-url-state.js +14 -8
- package/dist/index.d.ts +5 -2
- package/dist/index.js +8 -0
- package/dist/lib/markdown-merge.d.ts +38 -0
- package/dist/lib/markdown-merge.js +202 -17
- package/dist/lib/page-leaving.d.ts +8 -0
- package/dist/lib/page-leaving.js +30 -0
- package/dist/lib/pending-edits.d.ts +14 -0
- package/dist/lib/pending-edits.js +51 -0
- package/dist/lib/rating-glyphs.d.ts +3 -0
- package/dist/lib/rating-glyphs.js +7 -0
- package/dist/mocks/e2e-hooks.js +10 -0
- package/dist/mocks/override.d.ts +8 -0
- package/dist/testing/index.d.ts +40 -2
- package/dist/testing/index.js +101 -7
- package/openapi/foundation.yaml +12 -0
- package/package.json +1 -1
- package/styles/index.css +7 -0
|
@@ -37,7 +37,16 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
37
37
|
// Markdown writes them (src/lib/markdown-table.ts).
|
|
38
38
|
// - Edited blocks are written in the document's own bullet and rule marks.
|
|
39
39
|
// - Markdown pasted as plain text arrives formatted (still no HTML), and a
|
|
40
|
-
// copy out of the editor is Markdown.
|
|
40
|
+
// copy out of the editor is Markdown. A paste keeps its lines, Word's
|
|
41
|
+
// and Notion's lists and to-dos, and code's language; an address pasted
|
|
42
|
+
// or typed becomes a link; a paste can't bring in a link that runs code
|
|
43
|
+
// or an image as `data:` (rich-text-paste.ts, rich-text-autolink.ts).
|
|
44
|
+
// - An edit the merge refuses is never saved quietly: the field is marked
|
|
45
|
+
// invalid, and says why in itself when the app gives no `onProblem`
|
|
46
|
+
// (with one, the app shows it: a form's field error, editing in
|
|
47
|
+
// place's line).
|
|
48
|
+
// - Full screen holds focus: the page behind it is inert until it ends
|
|
49
|
+
// (rich-text-full-screen.ts).
|
|
41
50
|
// - A click on a link opens it in a new tab, as the read view's links do,
|
|
42
51
|
// so notes that are always the editor still follow their links
|
|
43
52
|
// (followLink). Ctrl/Cmd+K adds or edits a link (a box at the caret: web
|
|
@@ -59,7 +68,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
59
68
|
// for notes that are always editable where they're read.
|
|
60
69
|
// - Images in the text show (``), at most the field's width.
|
|
61
70
|
// With `upload`, an image pasted, dropped or picked with the toolbar's
|
|
62
|
-
// Image button
|
|
71
|
+
// Image button (the fixed toolbar's, the tools strip's with
|
|
72
|
+
// `toolbar="floating"`, the phone's row) is uploaded through it and goes in as ``
|
|
63
73
|
// (rich-text-image-upload.ts); a refusal or a failed upload is a toast.
|
|
64
74
|
// - Toggle headings (`## Safety {toggle="true"}`, rich-text-toggle-heading.ts):
|
|
65
75
|
// a heading's `toggle` attribute, typed as `>## `, picked from the slash
|
|
@@ -76,11 +86,10 @@ import { createPortal } from 'react-dom';
|
|
|
76
86
|
import { useInRouterContext, useNavigate } from 'react-router';
|
|
77
87
|
import { defaultValueCtx, Editor, editorViewCtx, editorViewOptionsCtx, parserCtx, remarkStringifyOptionsCtx, rootCtx, schemaCtx, serializerCtx, } from '@milkdown/kit/core';
|
|
78
88
|
import { history } from '@milkdown/kit/plugin/history';
|
|
79
|
-
import { commands, headingSchema, paragraphSchema,
|
|
89
|
+
import { commands, headingSchema, paragraphSchema, keymap, plugins, remarkPreserveEmptyLinePlugin, schema, } from '@milkdown/kit/preset/commonmark';
|
|
80
90
|
import { gfm, tableCellSchema, tableHeaderSchema, tableSchema } from '@milkdown/kit/preset/gfm';
|
|
81
|
-
import { Fragment, Slice } from '@milkdown/kit/prose/model';
|
|
82
91
|
import { NodeSelection, Plugin, TextSelection } from '@milkdown/kit/prose/state';
|
|
83
|
-
import { isInTable, TableMap } from '@milkdown/kit/prose/tables';
|
|
92
|
+
import { isInTable, selectedRect, TableMap } from '@milkdown/kit/prose/tables';
|
|
84
93
|
import { Decoration, DecorationSet } from '@milkdown/kit/prose/view';
|
|
85
94
|
import { $markSchema, $nodeSchema, $prose, $remark, getMarkdown } from '@milkdown/kit/utils';
|
|
86
95
|
import { cn } from 'cn';
|
|
@@ -100,16 +109,20 @@ import { formatTableWidths, remarkTableWidths } from '../../lib/markdown-table-w
|
|
|
100
109
|
import { DEFAULT_HIGHLIGHT, highlightHandler, isHighlightColor, remarkHighlightNodes } from '../../lib/markdown-highlight.js';
|
|
101
110
|
import { textTopHeading } from '../../lib/markdown-top-heading.js';
|
|
102
111
|
import { MarkdownMergeError, markdownStyle, mergeMarkdown } from '../../lib/markdown-merge.js';
|
|
112
|
+
import { holdPendingEdit } from '../../lib/pending-edits.js';
|
|
103
113
|
import { foldStore, listenForOtherTabs } from '../../hooks/fold-store.js';
|
|
104
114
|
import { toggleFold } from '../../lib/markdown-fold.js';
|
|
105
115
|
import { DEFAULT_HEADING_LEVEL, FOLD_BUTTON, FOLD_HEADING, headingBand, headingClass, headingTag } from './prose-look.js';
|
|
106
116
|
import { foldPlugin, foldSpecOf, setFolds } from './rich-text-fold.js';
|
|
107
117
|
import { RichTextFloatingToolbar } from './rich-text-floating-toolbar.js';
|
|
108
|
-
import { tableAt, toggleFormat } from './rich-text-formats.js';
|
|
118
|
+
import { formatOn, tableAt, toggleFormat } from './rich-text-formats.js';
|
|
119
|
+
import { CALLOUT_VARIANTS, FORMAT_GROUPS, HIGHLIGHT_VARIANTS, TOGGLE_HEADING_VARIANTS } from './rich-text-format-items.js';
|
|
109
120
|
import { calloutKind, calloutView, tableView } from './rich-text-node-views.js';
|
|
110
121
|
import { droppedFiles, imageUploadPlugin, pastedImages, uploadImages, uploadPlaceholders } from './rich-text-image-upload.js';
|
|
111
122
|
import { handleShortcut } from './rich-text-shortcuts.js';
|
|
112
|
-
import { splitTaskItem, taskInputRule } from './rich-text-tasks.js';
|
|
123
|
+
import { splitTaskItem, TASK_ROW, taskBoxHit, taskInputRule } from './rich-text-tasks.js';
|
|
124
|
+
import { typedInputRules } from './rich-text-input-rules.js';
|
|
125
|
+
import { edges } from './rich-text-edges.js';
|
|
113
126
|
import { withEmptyParagraphChildren } from './rich-text-empty-paragraph.js';
|
|
114
127
|
import { toggleHeadingInputRule, toggleHeadingRemark, withToggle } from './rich-text-toggle-heading.js';
|
|
115
128
|
import { addRowAtEnd, colorTableCells, fitAllColumns, handleTableKey, previewColumnWidth, runTableAction, setColumnWidth, tableLook as tableLookPlugin, tableWidthsOf } from './rich-text-table.js';
|
|
@@ -118,14 +131,18 @@ import { applySlash, clearSlash, closeSlash, slashItems, slashOptionId, slashPlu
|
|
|
118
131
|
import { RichTextSlashMenu } from './rich-text-slash-menu.js';
|
|
119
132
|
import { RichTextToolbar } from './rich-text-toolbar.js';
|
|
120
133
|
import { RichTextToolsBar } from './rich-text-tools-bar.js';
|
|
134
|
+
import { RichTextKeyboardBar } from './rich-text-keyboard-bar.js';
|
|
135
|
+
import { useCoarsePointer } from './rich-text-touch.js';
|
|
136
|
+
import { autolinkPlugin, linkWordBefore } from './rich-text-autolink.js';
|
|
137
|
+
import { useHoldFocus } from './rich-text-full-screen.js';
|
|
138
|
+
import { cleanPasted, NO_IMAGES_HERE, pasteHtml, pasteLinesIntoCell, pastePlainText } from './rich-text-paste.js';
|
|
121
139
|
import { CalloutKindMenu, TableBar } from './rich-text-widgets.js';
|
|
122
140
|
// The commonmark preset, minus the plugin that writes `<br />`. A $remark
|
|
123
141
|
// plugin is a pair (its options and the plugin), spread into `plugins`.
|
|
124
142
|
const LEFT_OUT = remarkPreserveEmptyLinePlugin;
|
|
125
143
|
const COMMONMARK = [
|
|
126
144
|
...schema,
|
|
127
|
-
...
|
|
128
|
-
...markInputRules,
|
|
145
|
+
...typedInputRules,
|
|
129
146
|
...commands,
|
|
130
147
|
...keymap,
|
|
131
148
|
...plugins.filter((plugin) => !LEFT_OUT.includes(plugin)),
|
|
@@ -230,22 +247,42 @@ function emptyImageTitles(node) {
|
|
|
230
247
|
node.children?.forEach(emptyImageTitles);
|
|
231
248
|
}
|
|
232
249
|
const imageTitles = $remark('imageTitles', () => () => (tree) => emptyImageTitles(tree));
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
250
|
+
// What the field says when the merge refuses an edit (markdown-merge.ts):
|
|
251
|
+
// to the app's `onProblem`, and in the field itself.
|
|
252
|
+
// How long typing has to stop before the edit is turned back into
|
|
253
|
+
// Markdown (mergeMarkdown) and reported through onChange (F6).
|
|
254
|
+
export const MERGE_PAUSE_MS = 300;
|
|
255
|
+
// Every format a toolbar can show as on.
|
|
256
|
+
const SHOWN_FORMATS = [
|
|
257
|
+
...new Set([...FORMAT_GROUPS.flat(), ...TOGGLE_HEADING_VARIANTS, ...CALLOUT_VARIANTS, ...HIGHLIGHT_VARIANTS].map((item) => item.id)),
|
|
258
|
+
];
|
|
259
|
+
// What the editor's React parts draw from its state, as one string: the
|
|
260
|
+
// formats on, the selection (where only when there is one: a caret's
|
|
261
|
+
// place matters to nothing drawn but the slash menu and a table's grips),
|
|
262
|
+
// the slash menu's query, a table's caret cell and the uploads. A key
|
|
263
|
+
// that doesn't change it re-renders nothing (F6).
|
|
264
|
+
function shownKey(state) {
|
|
265
|
+
const { selection } = state;
|
|
266
|
+
const parts = [selection.empty ? 'caret' : `${selection.from}-${selection.to}`];
|
|
267
|
+
if (selection instanceof NodeSelection)
|
|
268
|
+
parts.push('node');
|
|
269
|
+
if (selection.$from.parent.type.spec.code)
|
|
270
|
+
parts.push('code');
|
|
271
|
+
if (!selection.empty && selection.$from.sameParent(selection.$to))
|
|
272
|
+
parts.push('one-block');
|
|
273
|
+
parts.push(SHOWN_FORMATS.filter((id) => formatOn(state, id)).join(','));
|
|
274
|
+
const slash = slashQuery(state);
|
|
275
|
+
if (slash)
|
|
276
|
+
parts.push(`slash:${slash.from}:${slash.to}:${slash.query}`);
|
|
277
|
+
const table = tableAt(state);
|
|
278
|
+
if (table && isInTable(state)) {
|
|
279
|
+
const { top, left } = selectedRect(state);
|
|
280
|
+
parts.push(`table:${table.pos}:${top}:${left}`);
|
|
281
|
+
}
|
|
282
|
+
parts.push(`uploads:${uploadPlaceholders(state).length}`);
|
|
283
|
+
return parts.join('|');
|
|
248
284
|
}
|
|
285
|
+
const REFUSED_EDIT = "This change can't be saved without rewriting parts of the text you didn't edit. Undo it to go on saving.";
|
|
249
286
|
// A heading: the element `headingLevel` gives its level, the look its
|
|
250
287
|
// level has. Marked as a band for PROSE_INSET (`#` and `##`).
|
|
251
288
|
//
|
|
@@ -346,7 +383,8 @@ function taskItemView(node, view, getPos) {
|
|
|
346
383
|
const contentDOM = document.createElement('div');
|
|
347
384
|
// Takes the row's width, so an empty item's caret and placeholder show.
|
|
348
385
|
contentDOM.className = 'min-w-0 flex-1';
|
|
349
|
-
dom.append(box, contentDOM);
|
|
386
|
+
dom.append(taskBoxHit(box), contentDOM);
|
|
387
|
+
dom.className = TASK_ROW;
|
|
350
388
|
dom.dataset.itemType = 'task';
|
|
351
389
|
let current = node;
|
|
352
390
|
const render = () => {
|
|
@@ -374,8 +412,8 @@ function taskItemView(node, view, getPos) {
|
|
|
374
412
|
render();
|
|
375
413
|
return true;
|
|
376
414
|
},
|
|
377
|
-
stopEvent: (event) => event.target === box,
|
|
378
|
-
ignoreMutation: (mutation) => mutation.target === box,
|
|
415
|
+
stopEvent: (event) => event.target === box || event.target === box.parentElement,
|
|
416
|
+
ignoreMutation: (mutation) => mutation.target === box || mutation.target === box.parentElement,
|
|
379
417
|
};
|
|
380
418
|
}
|
|
381
419
|
// The task-list item the caret is in, ticked or unticked. False when the
|
|
@@ -516,6 +554,8 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
516
554
|
const navigateRef = useRef(null);
|
|
517
555
|
const inRouter = useInRouterContext();
|
|
518
556
|
const [length, setLength] = useState(defaultValue.length);
|
|
557
|
+
// Why the last edit can't be saved, shown in the field (REFUSED_EDIT).
|
|
558
|
+
const [refused, setRefused] = useState(null);
|
|
519
559
|
// The editor's state after each change, for the toolbar's pressed buttons.
|
|
520
560
|
const [editorState, setEditorState] = useState(null);
|
|
521
561
|
const [editorView, setEditorView] = useState(null);
|
|
@@ -523,7 +563,16 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
523
563
|
// toolbar), the mouse is down choosing words, and the selection Esc hid
|
|
524
564
|
// it for.
|
|
525
565
|
const [focused, setFocused] = useState(false);
|
|
526
|
-
const [selecting,
|
|
566
|
+
const [selecting, setSelectingState] = useState(false);
|
|
567
|
+
// Set only when it changes: a key sets it false, and React would draw
|
|
568
|
+
// the whole editor again for the first key after a click (F6).
|
|
569
|
+
const selectingRef = useRef(false);
|
|
570
|
+
const setSelecting = (next) => {
|
|
571
|
+
if (selectingRef.current === next)
|
|
572
|
+
return;
|
|
573
|
+
selectingRef.current = next;
|
|
574
|
+
setSelectingState(next);
|
|
575
|
+
};
|
|
527
576
|
const [dismissed, setDismissed] = useState(null);
|
|
528
577
|
const toolbarRef = useRef(null);
|
|
529
578
|
const floatingRef = useRef(null);
|
|
@@ -564,20 +613,29 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
564
613
|
document.body.style.overflow = overflow;
|
|
565
614
|
};
|
|
566
615
|
}, [fullScreen]);
|
|
616
|
+
// The page behind full screen is inert meanwhile (rich-text-full-screen.ts).
|
|
617
|
+
useHoldFocus(field, fullScreen);
|
|
567
618
|
// The toolbar's Image button opens this file picker.
|
|
568
619
|
const imageInputRef = useRef(null);
|
|
569
620
|
// The fixed bar above the text, and the menus over it (the floating
|
|
570
621
|
// toolbar and the slash menu), which `'floating'` keeps on their own.
|
|
571
|
-
|
|
622
|
+
// On a touch screen, the bar pinned to the keyboard in their place
|
|
623
|
+
// (rich-text-keyboard-bar.tsx).
|
|
624
|
+
const coarse = useCoarsePointer();
|
|
625
|
+
const fixedToolbar = toolbar === true && !coarse;
|
|
572
626
|
const menus = toolbar !== false;
|
|
573
627
|
const ids = useId();
|
|
574
628
|
const counterId = `${ids}-count`;
|
|
629
|
+
const problemId = `${ids}-problem`;
|
|
575
630
|
// The editable element's id: the app's, or one of its own, so the
|
|
576
631
|
// toolbar can name what it controls.
|
|
577
632
|
const editableId = id ?? `${ids}-text`;
|
|
578
633
|
// The count shows from 80% of the limit: below that it's noise.
|
|
579
634
|
const showCount = maxLength !== undefined && length >= maxLength * 0.8;
|
|
580
|
-
|
|
635
|
+
// The field says it itself when the app hears of it through no
|
|
636
|
+
// `onProblem` (a form that passes none would save the old text quietly).
|
|
637
|
+
const ownProblem = onProblem ? null : refused;
|
|
638
|
+
const describedBy = [ariaDescribedBy, ownProblem ? problemId : undefined, showCount ? counterId : undefined].filter(Boolean).join(' ');
|
|
581
639
|
const attributes = {
|
|
582
640
|
'aria-multiline': 'true',
|
|
583
641
|
'aria-readonly': String(readOnly),
|
|
@@ -590,7 +648,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
590
648
|
attributes['aria-labelledby'] = ariaLabelledBy;
|
|
591
649
|
if (describedBy)
|
|
592
650
|
attributes['aria-describedby'] = describedBy;
|
|
593
|
-
if (ariaInvalid)
|
|
651
|
+
if (ariaInvalid || refused)
|
|
594
652
|
attributes['aria-invalid'] = 'true';
|
|
595
653
|
if (placeholder)
|
|
596
654
|
attributes['aria-placeholder'] = placeholder;
|
|
@@ -599,7 +657,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
599
657
|
// The slash menu: open while a "/" typed at a line's start is followed
|
|
600
658
|
// by something some block answers to, and the field has focus.
|
|
601
659
|
const slash = menus && !readOnly && focused && editorState ? slashQuery(editorState) : null;
|
|
602
|
-
const slashMatches = slash ? slashItems(slash.query, { page: Boolean(onCreatePage), image: Boolean(upload) }) : [];
|
|
660
|
+
const slashMatches = slash ? slashItems(slash.query, { page: Boolean(onCreatePage), image: Boolean(upload), at: editorState ? { state: editorState, span: slash } : undefined }) : [];
|
|
603
661
|
const slashOpen = slash !== null && slashMatches.length > 0;
|
|
604
662
|
const slashMenuKey = slash ? `${slash.from}:${slash.query}` : '';
|
|
605
663
|
const slashIndex = slashActive.key === slashMenuKey ? Math.min(slashActive.index, slashMatches.length - 1) : 0;
|
|
@@ -622,13 +680,35 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
622
680
|
const textTop = headingFrom === 'text' ? textTopHeading(original) : 1;
|
|
623
681
|
let baseline = null;
|
|
624
682
|
let cancelled = false;
|
|
683
|
+
// The last shownKey React drew.
|
|
684
|
+
let shown = '';
|
|
685
|
+
// The merge runs a pause after typing stops (MERGE_PAUSE_MS), not on
|
|
686
|
+
// every key: its cost grows with the note (F6). Anything about to read
|
|
687
|
+
// the value first asks for it (flushPendingEdits, src/lib/pending-edits.ts),
|
|
688
|
+
// and leaving the text, Esc, Ctrl/Cmd+Enter, hiding the page and
|
|
689
|
+
// unmounting report it at once.
|
|
690
|
+
let pause;
|
|
691
|
+
let release = null;
|
|
692
|
+
const editedSoon = () => {
|
|
693
|
+
clearTimeout(pause);
|
|
694
|
+
pause = setTimeout(emit, MERGE_PAUSE_MS);
|
|
695
|
+
if (!release)
|
|
696
|
+
release = holdPendingEdit(emit);
|
|
697
|
+
};
|
|
625
698
|
const emit = () => {
|
|
699
|
+
clearTimeout(pause);
|
|
700
|
+
pause = undefined;
|
|
701
|
+
if (!release)
|
|
702
|
+
return;
|
|
703
|
+
release();
|
|
704
|
+
release = null;
|
|
626
705
|
const editor = editorRef.current;
|
|
627
706
|
if (!editor || baseline === null)
|
|
628
707
|
return;
|
|
629
708
|
const current = editor.action(getMarkdown());
|
|
630
709
|
try {
|
|
631
710
|
const merged = mergeMarkdown(original, baseline, current);
|
|
711
|
+
setRefused(null);
|
|
632
712
|
latest.current.onProblem?.(null);
|
|
633
713
|
latest.current.onChange(merged);
|
|
634
714
|
setLength(merged.length);
|
|
@@ -636,7 +716,10 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
636
716
|
catch (error) {
|
|
637
717
|
if (!(error instanceof MarkdownMergeError))
|
|
638
718
|
throw error;
|
|
639
|
-
|
|
719
|
+
// onChange isn't called: the app keeps the last text that could
|
|
720
|
+
// be saved, and the field says why it stopped.
|
|
721
|
+
setRefused(REFUSED_EDIT);
|
|
722
|
+
latest.current.onProblem?.(REFUSED_EDIT);
|
|
640
723
|
}
|
|
641
724
|
};
|
|
642
725
|
const changes = $prose(() => new Plugin({
|
|
@@ -644,16 +727,31 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
644
727
|
update: (view, previous) => {
|
|
645
728
|
if (cancelled)
|
|
646
729
|
return;
|
|
647
|
-
|
|
648
|
-
//
|
|
649
|
-
|
|
650
|
-
|
|
730
|
+
// React hears of the state only when something it draws
|
|
731
|
+
// from it changed (shownKey): most keys re-render nothing.
|
|
732
|
+
const key = shownKey(view.state);
|
|
733
|
+
if (key !== shown) {
|
|
734
|
+
shown = key;
|
|
735
|
+
setEditorState(view.state);
|
|
736
|
+
// Esc hides the floating toolbar for one selection only.
|
|
737
|
+
if (view.state.selection.empty)
|
|
738
|
+
setDismissed(null);
|
|
739
|
+
}
|
|
651
740
|
if (!view.state.doc.eq(previous.doc))
|
|
652
|
-
|
|
741
|
+
editedSoon();
|
|
653
742
|
},
|
|
654
743
|
}),
|
|
655
744
|
props: {
|
|
656
|
-
|
|
745
|
+
// Word's lists, to-dos and code languages, before the HTML is read.
|
|
746
|
+
transformPastedHTML: (html) => pasteHtml(html),
|
|
747
|
+
// No HTML, no link that runs code, no image as `data:`; in a
|
|
748
|
+
// cell, one line (rich-text-paste.ts).
|
|
749
|
+
transformPasted: (slice, view) => {
|
|
750
|
+
const { slice: cleaned, images, dropped } = cleanPasted(view, slice, Boolean(latest.current.upload));
|
|
751
|
+
if (images.length > 0 || dropped > 0)
|
|
752
|
+
setTimeout(() => pastedImagesLanded(view, { images, dropped }), 0);
|
|
753
|
+
return cleaned;
|
|
754
|
+
},
|
|
657
755
|
},
|
|
658
756
|
}));
|
|
659
757
|
// The node views' slots, by slot; React hears of a change once per
|
|
@@ -704,6 +802,8 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
704
802
|
// made will be linked.
|
|
705
803
|
const pageLinks = $prose(() => pageLinksPlugin({ resolve: () => latest.current.pageLink, restore: restorePage, editable: () => !latest.current.readOnly }));
|
|
706
804
|
const pendingPages = $prose(() => pendingPagePlugin());
|
|
805
|
+
// An address typed and ended with a space becomes a link.
|
|
806
|
+
const autolink = $prose(() => autolinkPlugin());
|
|
707
807
|
// Images pasted or dropped, uploaded through the app's `upload`; with
|
|
708
808
|
// none given, a paste or drop is left to the handlers after this one,
|
|
709
809
|
// as if this weren't here.
|
|
@@ -715,26 +815,49 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
715
815
|
uploadImages(view, files, at, { upload: send, accept, maxSize, onError: (message) => toast.error(message) });
|
|
716
816
|
return true;
|
|
717
817
|
};
|
|
818
|
+
// Images a paste carried as `data:`: uploaded at the caret once the
|
|
819
|
+
// paste is in, or, with no `upload`, said no to.
|
|
820
|
+
const pastedImagesLanded = (view, { images, dropped }) => {
|
|
821
|
+
if (cancelled || view.isDestroyed)
|
|
822
|
+
return;
|
|
823
|
+
if (images.length > 0)
|
|
824
|
+
startUploads(view, images, null);
|
|
825
|
+
if (dropped > 0)
|
|
826
|
+
toast.error(NO_IMAGES_HERE);
|
|
827
|
+
};
|
|
718
828
|
const imageInput = $prose(() => new Plugin({
|
|
719
829
|
props: {
|
|
830
|
+
// Without `upload`, an image file pasted or dropped says it
|
|
831
|
+
// can't go in (any words with it still paste).
|
|
720
832
|
handlePaste: (view, event) => {
|
|
721
|
-
if (!
|
|
833
|
+
if (!view.editable)
|
|
722
834
|
return false;
|
|
723
835
|
const files = pastedImages(event.clipboardData);
|
|
724
836
|
if (files.length === 0)
|
|
725
837
|
return false;
|
|
838
|
+
if (!latest.current.upload) {
|
|
839
|
+
toast.error(NO_IMAGES_HERE);
|
|
840
|
+
if (event.clipboardData?.getData('text/plain'))
|
|
841
|
+
return false;
|
|
842
|
+
event.preventDefault();
|
|
843
|
+
return true;
|
|
844
|
+
}
|
|
726
845
|
event.preventDefault();
|
|
727
846
|
return startUploads(view, files, null);
|
|
728
847
|
},
|
|
729
848
|
// Files from outside (a text or an image moved within the
|
|
730
849
|
// editor carries none).
|
|
731
850
|
handleDrop: (view, event, _slice, moved) => {
|
|
732
|
-
if (moved || !
|
|
851
|
+
if (moved || !view.editable)
|
|
733
852
|
return false;
|
|
734
853
|
const files = droppedFiles(event.dataTransfer);
|
|
735
854
|
if (files.length === 0)
|
|
736
855
|
return false;
|
|
737
856
|
event.preventDefault();
|
|
857
|
+
if (!latest.current.upload) {
|
|
858
|
+
toast.error(NO_IMAGES_HERE);
|
|
859
|
+
return true;
|
|
860
|
+
}
|
|
738
861
|
const at = view.posAtCoords({ left: event.clientX, top: event.clientY })?.pos ?? view.state.selection.from;
|
|
739
862
|
return startUploads(view, files, at);
|
|
740
863
|
},
|
|
@@ -745,26 +868,19 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
745
868
|
// Plain text is read as Markdown, so `## Notes` or `**bold**`
|
|
746
869
|
// copied from another app arrives formatted; raw HTML in it
|
|
747
870
|
// still arrives as text. A paste with HTML of its own (from a
|
|
748
|
-
// web page) is ProseMirror's, through transformPasted above
|
|
871
|
+
// web page) is ProseMirror's, through transformPasted above,
|
|
872
|
+
// but for an address pasted over words, which links them
|
|
873
|
+
// (rich-text-paste.ts).
|
|
749
874
|
handlePaste: (view, event) => {
|
|
750
875
|
const data = event.clipboardData;
|
|
751
|
-
if (!data || !view.editable
|
|
752
|
-
return false;
|
|
753
|
-
const text = data.getData('text/plain');
|
|
754
|
-
if (!text || view.state.selection.$from.parent.type.spec.code)
|
|
755
|
-
return false;
|
|
756
|
-
const parsed = ctx.get(parserCtx)(text);
|
|
757
|
-
if (!parsed || typeof parsed === 'string')
|
|
876
|
+
if (!data || !view.editable)
|
|
758
877
|
return false;
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
}
|
|
766
|
-
view.dispatch(view.state.tr.replaceSelection(Slice.maxOpen(htmlToText(parsed.content))).scrollIntoView());
|
|
767
|
-
return true;
|
|
878
|
+
return pastePlainText(view, data.getData('text/plain'), {
|
|
879
|
+
parse: (markdown) => ctx.get(parserCtx)(markdown),
|
|
880
|
+
hasHtml: Boolean(data.getData('text/html')),
|
|
881
|
+
uploads: Boolean(latest.current.upload),
|
|
882
|
+
onImages: (images) => pastedImagesLanded(view, images),
|
|
883
|
+
});
|
|
768
884
|
},
|
|
769
885
|
// A copy is Markdown, so it pastes into a plain text field
|
|
770
886
|
// (or another Markdown editor) as written.
|
|
@@ -780,7 +896,9 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
780
896
|
return false;
|
|
781
897
|
},
|
|
782
898
|
// Moving to the floating toolbar keeps it showing.
|
|
899
|
+
// Leaving the text reports what was typed (F6).
|
|
783
900
|
blur: (_view, event) => {
|
|
901
|
+
emit();
|
|
784
902
|
if (!inFloating(event.relatedTarget))
|
|
785
903
|
setFocused(false);
|
|
786
904
|
return false;
|
|
@@ -803,6 +921,10 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
803
921
|
},
|
|
804
922
|
handleKeyDown: (view, event) => {
|
|
805
923
|
setSelecting(false);
|
|
924
|
+
// Esc and Ctrl/Cmd+Enter are the field's (save, close): what
|
|
925
|
+
// was typed is reported before they reach it (F6).
|
|
926
|
+
if (event.key === 'Escape' || (event.key === 'Enter' && (event.metaKey || event.ctrlKey)))
|
|
927
|
+
emit();
|
|
806
928
|
// Alt+F10: to the floating toolbar when it shows, else the
|
|
807
929
|
// fixed one (the convention editors share).
|
|
808
930
|
if (event.altKey && event.key === 'F10') {
|
|
@@ -880,6 +1002,14 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
880
1002
|
...options,
|
|
881
1003
|
editable: () => !latest.current.readOnly,
|
|
882
1004
|
attributes,
|
|
1005
|
+
// Lines pasted into a table cell: one line, before the table's
|
|
1006
|
+
// own paste spreads them over the row (rich-text-paste.ts).
|
|
1007
|
+
handlePaste: (view, event) => {
|
|
1008
|
+
const data = event.clipboardData;
|
|
1009
|
+
if (!data || !view.editable || data.getData('text/html'))
|
|
1010
|
+
return false;
|
|
1011
|
+
return pasteLinesIntoCell(view, data.getData('text/plain'));
|
|
1012
|
+
},
|
|
883
1013
|
// The slash menu's keys, the editor's own shortcuts and its table
|
|
884
1014
|
// keys, as view props: before Milkdown's own keymap, whose Enter
|
|
885
1015
|
// would split the line (or leave a table).
|
|
@@ -929,6 +1059,9 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
929
1059
|
return true;
|
|
930
1060
|
}
|
|
931
1061
|
}
|
|
1062
|
+
// Enter after a typed address links it first (rich-text-autolink.ts).
|
|
1063
|
+
if (event.key === 'Enter' && !event.isComposing && !event.metaKey && !event.ctrlKey)
|
|
1064
|
+
linkWordBefore(view);
|
|
932
1065
|
// Enter in a task item: the next one, unticked (rich-text-tasks.ts).
|
|
933
1066
|
if (event.key === 'Enter' && plain && !event.isComposing && splitTaskItem(view.state, view.dispatch))
|
|
934
1067
|
return true;
|
|
@@ -947,6 +1080,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
947
1080
|
},
|
|
948
1081
|
}));
|
|
949
1082
|
})
|
|
1083
|
+
.use(edges)
|
|
950
1084
|
.use(COMMONMARK)
|
|
951
1085
|
.use(gfm)
|
|
952
1086
|
.use(taskInputRule)
|
|
@@ -970,6 +1104,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
970
1104
|
.use(imageUploads)
|
|
971
1105
|
.use(imageInput)
|
|
972
1106
|
.use(input)
|
|
1107
|
+
.use(autolink)
|
|
973
1108
|
.use(folds);
|
|
974
1109
|
void make.create().then((editor) => {
|
|
975
1110
|
if (cancelled) {
|
|
@@ -980,6 +1115,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
980
1115
|
baseline = editor.action(getMarkdown());
|
|
981
1116
|
const view = editor.action((ctx) => ctx.get(editorViewCtx));
|
|
982
1117
|
setEditorView(view);
|
|
1118
|
+
shown = shownKey(view.state);
|
|
983
1119
|
setEditorState(view.state);
|
|
984
1120
|
if (autoFocus)
|
|
985
1121
|
editor.action((ctx) => ctx.get(editorViewCtx).focus());
|
|
@@ -988,7 +1124,19 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
988
1124
|
stopFolds = foldStore.subscribe(foldKey, () => view.dispatch(setFolds(view.state, foldStore.get(foldKey))));
|
|
989
1125
|
}
|
|
990
1126
|
});
|
|
1127
|
+
// Hiding the page (another tab, a phone's home screen) reports what
|
|
1128
|
+
// was typed: the page may not come back.
|
|
1129
|
+
const onHidden = () => {
|
|
1130
|
+
if (document.visibilityState === 'hidden')
|
|
1131
|
+
emit();
|
|
1132
|
+
};
|
|
1133
|
+
document.addEventListener('visibilitychange', onHidden);
|
|
1134
|
+
window.addEventListener('pagehide', emit);
|
|
991
1135
|
return () => {
|
|
1136
|
+
document.removeEventListener('visibilitychange', onHidden);
|
|
1137
|
+
window.removeEventListener('pagehide', emit);
|
|
1138
|
+
// Unmounting reports what was typed since the last pause.
|
|
1139
|
+
emit();
|
|
992
1140
|
cancelled = true;
|
|
993
1141
|
stopFolds();
|
|
994
1142
|
setEditorState(null);
|
|
@@ -1144,10 +1292,18 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
1144
1292
|
editorView.focus();
|
|
1145
1293
|
};
|
|
1146
1294
|
const caretTable = editorState ? tableAt(editorState)?.pos : undefined;
|
|
1295
|
+
// The caret's cell, for its table's grips: only while the text has focus.
|
|
1296
|
+
const caretCell = (() => {
|
|
1297
|
+
if (!focused || !editorState || caretTable === undefined || !isInTable(editorState))
|
|
1298
|
+
return null;
|
|
1299
|
+
const { top, left } = selectedRect(editorState);
|
|
1300
|
+
return { row: top, column: left };
|
|
1301
|
+
})();
|
|
1147
1302
|
// The floating toolbar: words selected, focus in the field, the mouse up,
|
|
1148
1303
|
// and nothing else open over the text.
|
|
1149
1304
|
const selection = editorState?.selection;
|
|
1150
1305
|
const floatingOpen = Boolean(menus &&
|
|
1306
|
+
!coarse &&
|
|
1151
1307
|
!readOnly &&
|
|
1152
1308
|
editorView &&
|
|
1153
1309
|
focused &&
|
|
@@ -1164,7 +1320,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
1164
1320
|
});
|
|
1165
1321
|
const returnToText = () => editorView?.focus();
|
|
1166
1322
|
// The tools strip of a field with only the floating toolbar.
|
|
1167
|
-
const toolsOpen = Boolean(toolbar === 'floating' && editorView && (focused || fullScreen));
|
|
1323
|
+
const toolsOpen = Boolean(toolbar === 'floating' && !coarse && editorView && (focused || fullScreen));
|
|
1168
1324
|
const toggleFullScreen = () => {
|
|
1169
1325
|
setFullScreen((on) => !on);
|
|
1170
1326
|
editorView?.focus();
|
|
@@ -1248,7 +1404,9 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
1248
1404
|
setLinkBox(null);
|
|
1249
1405
|
editorRef.current?.action((ctx) => ctx.get(editorViewCtx).focus());
|
|
1250
1406
|
};
|
|
1251
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: setField, "data-slot": "rich-text-editor", "data-table-look": tableLook, "data-full-screen": fullScreen || undefined,
|
|
1407
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: setField, "data-slot": "rich-text-editor", "data-table-look": tableLook, "data-full-screen": fullScreen || undefined,
|
|
1408
|
+
// Full screen is a dialog over the page, named as the field is.
|
|
1409
|
+
role: fullScreen ? 'dialog' : undefined, "aria-modal": fullScreen || undefined, "aria-labelledby": fullScreen ? ariaLabelledBy : undefined, "aria-label": fullScreen && !ariaLabelledBy ? (ariaLabel ?? 'Text') : undefined, onKeyDown: leaveFullScreen, className: cn(fullScreen ? 'fixed inset-0 z-50 h-dvh rounded-none! border-0! bg-background! ring-0!' : 'relative', 'flex w-full min-w-0 flex-col bg-transparent type-body text-foreground break-words',
|
|
1252
1410
|
// Inline, it's the text itself: the caret shows where it's
|
|
1253
1411
|
// edited, and a refusal's reason under it says what's wrong.
|
|
1254
1412
|
!inline &&
|
|
@@ -1275,7 +1433,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
1275
1433
|
// as typed, so one at the end of a line isn't kept as .
|
|
1276
1434
|
'[&_.ProseMirror]:whitespace-pre-wrap [&_.ProseMirror]:break-words', '[&_ul]:flex [&_ul]:list-disc [&_ul]:flex-col [&_ul]:gap-1 [&_ul]:pl-6', '[&_ol]:flex [&_ol]:list-decimal [&_ol]:flex-col [&_ol]:gap-1 [&_ol]:pl-6', '[&_li[data-item-type=task]]:-ml-6 [&_li[data-item-type=task]]:flex [&_li[data-item-type=task]]:list-none [&_li[data-item-type=task]]:items-start [&_li[data-item-type=task]]:gap-2',
|
|
1277
1435
|
// Highlighted words: the colour's wash, the text's own colour on it.
|
|
1278
|
-
'[&_mark]:rounded-sm [&_mark]:text-foreground [&_mark[data-color=amber]]:bg-highlight-amber [&_mark[data-color=yellow]]:bg-highlight-yellow [&_mark[data-color=green]]:bg-highlight-green [&_mark[data-color=red]]:bg-highlight-red',
|
|
1436
|
+
'[&_mark]:rounded-sm [&_mark]:text-foreground [&_mark[data-color=amber]]:bg-highlight-amber [&_mark[data-color=yellow]]:bg-highlight-yellow [&_mark[data-color=green]]:bg-highlight-green [&_mark[data-color=red]]:bg-highlight-red',
|
|
1279
1437
|
// Headings, callouts and tables are drawn by their node views;
|
|
1280
1438
|
// these are the elements Milkdown draws itself.
|
|
1281
1439
|
'[&_a]:cursor-pointer [&_a]:text-link [&_a]:underline [&_a]:decoration-link/40 [&_a]:underline-offset-4', '[&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-4 [&_blockquote]:text-muted-foreground', '[&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:bg-muted [&_pre]:p-3 [&_pre]:font-mono', '[&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-muted [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:font-mono', '[&_hr]:my-2 [&_hr]:h-0.5 [&_hr]:rounded-full [&_hr]:border-0 [&_hr]:bg-rule', '[&_hr.ProseMirror-selectednode]:outline-2 [&_hr.ProseMirror-selectednode]:outline-offset-4 [&_hr.ProseMirror-selectednode]:outline-ring',
|
|
@@ -1286,7 +1444,7 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
1286
1444
|
// Raw HTML from the text: shown as its characters, never as markup.
|
|
1287
1445
|
'[&_span[data-type=html]]:rounded [&_span[data-type=html]]:bg-muted [&_span[data-type=html]]:px-1 [&_span[data-type=html]]:font-mono [&_span[data-type=html]]:text-foreground',
|
|
1288
1446
|
// The placeholder, in an empty document only (a decoration).
|
|
1289
|
-
'[&_p[data-placeholder]]:before:pointer-events-none [&_p[data-placeholder]]:before:float-left [&_p[data-placeholder]]:before:h-0 [&_p[data-placeholder]]:before:text-muted-foreground [&_p[data-placeholder]]:before:content-[attr(data-placeholder)]') }), widgets.map((widget) => {
|
|
1447
|
+
'[&_p[data-placeholder]]:before:pointer-events-none [&_p[data-placeholder]]:before:float-left [&_p[data-placeholder]]:before:h-0 [&_p[data-placeholder]]:before:text-muted-foreground [&_p[data-placeholder]]:before:content-[attr(data-placeholder)]') }), ownProblem && (_jsx("p", { id: problemId, role: "alert", "data-slot": "rich-text-editor-problem", className: cn('type-caption text-destructive-text', inline ? 'pt-1' : 'border-t border-border px-2.5 py-1.5', fullScreen && 'px-4 md:px-8'), children: ownProblem })), widgets.map((widget) => {
|
|
1290
1448
|
if (widget.type === 'callout')
|
|
1291
1449
|
return createPortal(_jsx(CalloutKindMenu, { kind: widget.kind, readOnly: readOnly, onPick: (kind) => changeCallout(widget.getPos, kind), onRemove: () => changeCallout(widget.getPos, null), text: textElement }), widget.slot, widget.key);
|
|
1292
1450
|
const active = caretTable !== undefined && caretTable === widget.getPos();
|
|
@@ -1294,13 +1452,17 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
1294
1452
|
createPortal(_jsx(TableBar, { side: "row", active: active, readOnly: readOnly, onAdd: () => addToTable(widget.getPos, 'row') }), widget.slot, `${widget.key}-row`),
|
|
1295
1453
|
createPortal(_jsx(TableBar, { side: "column", active: active, readOnly: readOnly, onAdd: () => addToTable(widget.getPos, 'column') }), widget.column, `${widget.key}-column`),
|
|
1296
1454
|
editorView &&
|
|
1297
|
-
createPortal(_jsx(TableGrips, { view: editorView,
|
|
1455
|
+
createPortal(_jsx(TableGrips, { view: editorView, caret: active ? caretCell : null, getPos: widget.getPos, frame: widget.frame, box: widget.box, table: widget.table, readOnly: readOnly, onAction: (cell, action) => runTableAt(widget.getPos, cell, action), onColor: (cell, scope, color) => colorTableAt(widget.getPos, cell, scope, color), onWidth: (column, width) => widthTableAt(widget.getPos, column, width), onPreviewWidth: (column, width) => previewTableWidth(widget.getPos, column, width), text: textElement }), widget.grips, `${widget.key}-grips`),
|
|
1298
1456
|
];
|
|
1299
1457
|
}), slashOpen && slash && editorView && (_jsx(RichTextSlashMenu, { id: slashListId, view: editorView, at: slash.to, field: field, items: slashMatches, active: slashIndex, onHighlight: (index) => setSlashActive({ key: slashMenuKey, index }), onPick: (item) => item === 'page'
|
|
1300
1458
|
? startPage(editorView, slash, '')
|
|
1301
1459
|
: item === 'image'
|
|
1302
1460
|
? pickSlashImage(editorView, slash)
|
|
1303
|
-
: applySlash(editorView, slash, item) })),
|
|
1461
|
+
: applySlash(editorView, slash, item) })), coarse && menus && editorView && (focused || fullScreen) && (_jsx(RichTextKeyboardBar, { ref: toolbarRef, pressing: selecting, view: editorView, state: editorState, readOnly: readOnly, controls: editableId, onFormat: runFormat, onImage: upload ? pickImages : undefined, onFullScreen: toggleFullScreen, fullScreen: fullScreen, text: textElement, onBlur: (event) => {
|
|
1462
|
+
const next = event.relatedTarget;
|
|
1463
|
+
if (!editorView.dom.contains(next) && !inFloating(next))
|
|
1464
|
+
setFocused(false);
|
|
1465
|
+
} })), toolsOpen && (_jsx(RichTextToolsBar, { ref: toolsRef, state: editorState, readOnly: readOnly, fullScreen: fullScreen, controls: editableId, onFormat: runFormat, onImage: upload ? pickImages : undefined, onFullScreen: toggleFullScreen, onReturn: returnToText, onBlur: (event) => {
|
|
1304
1466
|
const next = event.relatedTarget;
|
|
1305
1467
|
if (editorView && !editorView.dom.contains(next) && !inFloating(next))
|
|
1306
1468
|
setFocused(false);
|
|
@@ -15,3 +15,19 @@ export type PillFilterProps = {
|
|
|
15
15
|
className?: string;
|
|
16
16
|
};
|
|
17
17
|
export declare function PillFilter({ label, options, value, onValueChange, allLabel, className }: PillFilterProps): import("react").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* One pill as PillGroup draws it: a PillFilterOption, and for DataTable's
|
|
20
|
+
* views (4.127) a count after the label, "Needs a Look · 3".
|
|
21
|
+
*/
|
|
22
|
+
export type PillGroupOption = PillFilterOption & {
|
|
23
|
+
/** The number shown after the label; null, undefined or 0 shows none, past 99 "99+". */
|
|
24
|
+
count?: number | null;
|
|
25
|
+
/**
|
|
26
|
+
* The pill keeps room for a two-digit count from its first render, so
|
|
27
|
+
* a count that arrives later (or never) moves no pill.
|
|
28
|
+
*/
|
|
29
|
+
counted?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare function PillGroup({ label, options, value, onValueChange, allLabel, className, }: Omit<PillFilterProps, 'options'> & {
|
|
32
|
+
options: readonly PillGroupOption[];
|
|
33
|
+
}): import("react").JSX.Element;
|