@zonsh/ui 0.5.0 → 0.6.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/CHANGELOG.md +643 -0
- package/README.md +49 -21
- package/dist/brand.d.ts +3 -0
- package/dist/brand.js +7 -0
- package/dist/components/_breadcrumb-more.d.ts +6 -0
- package/dist/components/_breadcrumb-more.js +5 -0
- package/dist/components/_drawing-svg.d.ts +11 -0
- package/dist/components/_drawing-svg.js +30 -0
- package/dist/components/_media.d.ts +159 -0
- package/dist/components/_media.js +266 -0
- package/dist/components/_overlay.d.ts +8 -5
- package/dist/components/_overlay.js +11 -6
- package/dist/components/_scheduler-calendar.d.ts +71 -0
- package/dist/components/_scheduler-calendar.js +940 -0
- package/dist/components/_scheduler-editor.d.ts +29 -0
- package/dist/components/_scheduler-editor.js +111 -0
- package/dist/components/_scheduler-menu.d.ts +16 -0
- package/dist/components/_scheduler-menu.js +18 -0
- package/dist/components/_scheduler-parts.d.ts +164 -0
- package/dist/components/_scheduler-parts.js +327 -0
- package/dist/components/_suggest-list.d.ts +142 -0
- package/dist/components/_suggest-list.js +159 -0
- package/dist/components/_toolbar-more.d.ts +24 -0
- package/dist/components/_toolbar-more.js +25 -0
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +6 -6
- package/dist/components/action-sheet.d.ts +88 -0
- package/dist/components/action-sheet.js +124 -0
- package/dist/components/alert-dialog.js +3 -1
- package/dist/components/alert.d.ts +11 -18
- package/dist/components/alert.js +9 -6
- package/dist/components/app-bar.d.ts +93 -0
- package/dist/components/app-bar.js +175 -0
- package/dist/components/audio-player.d.ts +134 -0
- package/dist/components/audio-player.js +618 -0
- package/dist/components/avatar.d.ts +6 -6
- package/dist/components/avatar.js +13 -11
- package/dist/components/badge.d.ts +12 -12
- package/dist/components/badge.js +7 -5
- package/dist/components/bottom-nav.d.ts +53 -11
- package/dist/components/bottom-nav.js +388 -23
- package/dist/components/breadcrumb.d.ts +11 -2
- package/dist/components/breadcrumb.js +60 -6
- package/dist/components/button-group.js +5 -1
- package/dist/components/button.d.ts +23 -6
- package/dist/components/button.js +63 -7
- package/dist/components/calendar.js +8 -6
- package/dist/components/card.d.ts +10 -8
- package/dist/components/card.js +15 -14
- package/dist/components/carousel.d.ts +2 -2
- package/dist/components/carousel.js +21 -8
- package/dist/components/chart.d.ts +27 -1
- package/dist/components/chart.js +15 -5
- package/dist/components/checkbox.js +2 -2
- package/dist/components/code-block.d.ts +9 -2
- package/dist/components/code-block.js +26 -7
- package/dist/components/collapsible.js +3 -3
- package/dist/components/color-picker.d.ts +2 -2
- package/dist/components/color-picker.js +5 -5
- package/dist/components/combobox.d.ts +26 -7
- package/dist/components/combobox.js +32 -13
- package/dist/components/command.d.ts +29 -5
- package/dist/components/command.js +35 -10
- package/dist/components/context-menu.d.ts +5 -2
- package/dist/components/context-menu.js +24 -3
- package/dist/components/conversation.d.ts +1 -1
- package/dist/components/conversation.js +67 -13
- package/dist/components/copy-button.d.ts +1 -1
- package/dist/components/copy-button.js +1 -1
- package/dist/components/data-table.d.ts +6 -6
- package/dist/components/data-table.js +41 -15
- package/dist/components/date-picker.d.ts +31 -9
- package/dist/components/date-picker.js +100 -18
- package/dist/components/dialog.d.ts +17 -10
- package/dist/components/dialog.js +20 -13
- package/dist/components/drawer.d.ts +26 -8
- package/dist/components/drawer.js +75 -16
- package/dist/components/drawing.d.ts +25 -0
- package/dist/components/drawing.js +32 -0
- package/dist/components/empty.js +2 -2
- package/dist/components/feature-list.d.ts +65 -13
- package/dist/components/feature-list.js +116 -15
- package/dist/components/field.js +2 -2
- package/dist/components/file-drop.d.ts +9 -7
- package/dist/components/file-drop.js +8 -43
- package/dist/components/filter-bar.d.ts +10 -9
- package/dist/components/filter-bar.js +42 -25
- package/dist/components/graph.d.ts +19 -3
- package/dist/components/graph.js +170 -25
- package/dist/components/illustration.js +3 -28
- package/dist/components/input-group.d.ts +5 -10
- package/dist/components/input-group.js +16 -16
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +3 -3
- package/dist/components/item.d.ts +9 -6
- package/dist/components/item.js +13 -8
- package/dist/components/kbd.d.ts +1 -1
- package/dist/components/kbd.js +1 -1
- package/dist/components/lightbox.d.ts +76 -9
- package/dist/components/lightbox.js +333 -45
- package/dist/components/locale.d.ts +6 -6
- package/dist/components/logo.d.ts +21 -1
- package/dist/components/logo.js +32 -2
- package/dist/components/markdown-editor.d.ts +275 -0
- package/dist/components/markdown-editor.js +831 -0
- package/dist/components/mentions.d.ts +153 -0
- package/dist/components/mentions.js +507 -0
- package/dist/components/menu.d.ts +2 -1
- package/dist/components/menu.js +5 -4
- package/dist/components/menubar.d.ts +23 -5
- package/dist/components/menubar.js +97 -22
- package/dist/components/message.d.ts +62 -11
- package/dist/components/message.js +49 -13
- package/dist/components/meter.js +1 -1
- package/dist/components/money-input.d.ts +1 -1
- package/dist/components/money-input.js +1 -1
- package/dist/components/native-select.d.ts +2 -2
- package/dist/components/native-select.js +4 -4
- package/dist/components/navigation-menu.d.ts +3 -1
- package/dist/components/navigation-menu.js +23 -12
- package/dist/components/number-field.d.ts +2 -9
- package/dist/components/number-field.js +86 -36
- package/dist/components/number-roll.d.ts +26 -0
- package/dist/components/number-roll.js +81 -0
- package/dist/components/otp-field.d.ts +1 -1
- package/dist/components/otp-field.js +24 -3
- package/dist/components/pagination.d.ts +11 -3
- package/dist/components/pagination.js +59 -13
- package/dist/components/pdf-viewer.d.ts +1 -1
- package/dist/components/pdf-viewer.js +8 -8
- package/dist/components/phone-input.d.ts +1 -1
- package/dist/components/phone-input.js +2 -2
- package/dist/components/popover.js +5 -3
- package/dist/components/preview-card.d.ts +37 -2
- package/dist/components/preview-card.js +226 -2
- package/dist/components/progress.js +1 -1
- package/dist/components/prompt-input.d.ts +1 -1
- package/dist/components/prompt-input.js +24 -14
- package/dist/components/pull-to-refresh.d.ts +50 -0
- package/dist/components/pull-to-refresh.js +189 -0
- package/dist/components/quote.d.ts +6 -1
- package/dist/components/quote.js +3 -2
- package/dist/components/radio-group.js +1 -1
- package/dist/components/rating.d.ts +4 -1
- package/dist/components/rating.js +131 -10
- package/dist/components/reasoning.d.ts +1 -1
- package/dist/components/reasoning.js +7 -3
- package/dist/components/resizable.d.ts +1 -1
- package/dist/components/resizable.js +2 -2
- package/dist/components/response.d.ts +1 -1
- package/dist/components/response.js +18 -6
- package/dist/components/scheduler.d.ts +352 -0
- package/dist/components/scheduler.js +1717 -0
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/select.d.ts +17 -4
- package/dist/components/select.js +140 -9
- package/dist/components/separator.d.ts +1 -1
- package/dist/components/separator.js +3 -3
- package/dist/components/sidebar.d.ts +44 -3
- package/dist/components/sidebar.js +57 -17
- package/dist/components/site-header.d.ts +18 -13
- package/dist/components/site-header.js +23 -11
- package/dist/components/skeleton.d.ts +17 -7
- package/dist/components/skeleton.js +22 -7
- package/dist/components/slider.js +2 -2
- package/dist/components/sortable.d.ts +55 -4
- package/dist/components/sortable.js +172 -103
- package/dist/components/sources.d.ts +1 -1
- package/dist/components/sources.js +2 -2
- package/dist/components/spinner.d.ts +4 -4
- package/dist/components/spinner.js +4 -4
- package/dist/components/stat.d.ts +21 -4
- package/dist/components/stat.js +17 -8
- package/dist/components/stepper.d.ts +1 -1
- package/dist/components/stepper.js +8 -7
- package/dist/components/suggestions.d.ts +11 -3
- package/dist/components/suggestions.js +10 -4
- package/dist/components/swipe-actions.d.ts +66 -0
- package/dist/components/swipe-actions.js +292 -0
- package/dist/components/switch.js +1 -1
- package/dist/components/table.d.ts +12 -6
- package/dist/components/table.js +78 -30
- package/dist/components/tabs.js +7 -4
- package/dist/components/tag.d.ts +19 -20
- package/dist/components/tag.js +9 -5
- package/dist/components/tags-input.d.ts +2 -7
- package/dist/components/tags-input.js +11 -8
- package/dist/components/textarea.d.ts +3 -2
- package/dist/components/textarea.js +4 -3
- package/dist/components/theme.d.ts +49 -6
- package/dist/components/theme.js +147 -9
- package/dist/components/time-field.d.ts +4 -9
- package/dist/components/time-field.js +6 -6
- package/dist/components/timeline.d.ts +19 -3
- package/dist/components/timeline.js +21 -9
- package/dist/components/tippy.d.ts +17 -1
- package/dist/components/tippy.js +95 -15
- package/dist/components/toast.d.ts +2 -7
- package/dist/components/toast.js +12 -8
- package/dist/components/toggle-group.d.ts +7 -1
- package/dist/components/toggle-group.js +16 -5
- package/dist/components/toggle.d.ts +2 -2
- package/dist/components/toggle.js +3 -2
- package/dist/components/tool-call.d.ts +1 -1
- package/dist/components/tool-call.js +4 -4
- package/dist/components/toolbar.d.ts +57 -4
- package/dist/components/toolbar.js +216 -16
- package/dist/components/tooltip.d.ts +1 -1
- package/dist/components/tooltip.js +4 -2
- package/dist/components/tour.d.ts +1 -1
- package/dist/components/tour.js +36 -15
- package/dist/components/tree.js +5 -5
- package/dist/components/typography.d.ts +31 -8
- package/dist/components/typography.js +21 -10
- package/dist/components/video-player.d.ts +7 -2
- package/dist/components/video-player.js +121 -220
- package/dist/index.d.ts +99 -92
- package/dist/index.js +99 -92
- package/dist/lib/calendar.d.ts +153 -0
- package/dist/lib/calendar.js +312 -0
- package/dist/lib/cn.d.ts +3 -1
- package/dist/lib/cn.js +5 -0
- package/dist/lib/code-highlight.d.ts +14 -0
- package/dist/lib/code-highlight.js +81 -18
- package/dist/lib/drag.d.ts +39 -0
- package/dist/lib/drag.js +96 -0
- package/dist/lib/editorial-assets.js +16 -8
- package/dist/lib/figure/figures/automation.js +25 -6
- package/dist/lib/figure/figures/bar-chart.js +6 -1
- package/dist/lib/figure/figures/brackets-classic.js +4 -1
- package/dist/lib/figure/figures/city.js +12 -2
- package/dist/lib/figure/figures/conveyor.js +17 -4
- package/dist/lib/figure/figures/database.js +5 -2
- package/dist/lib/figure/figures/documents.js +11 -3
- package/dist/lib/figure/figures/inbox.js +5 -2
- package/dist/lib/figure/figures/laptop.js +3 -1
- package/dist/lib/figure/figures/pipeline.js +45 -10
- package/dist/lib/figure/figures/platform.js +62 -7
- package/dist/lib/figure/figures/server.js +21 -5
- package/dist/lib/figure/figures/spreadsheet.js +29 -5
- package/dist/lib/figure/kernel.d.ts +4 -2
- package/dist/lib/figure/kernel.js +10 -5
- package/dist/lib/figure/parts.js +6 -2
- package/dist/lib/files.d.ts +31 -0
- package/dist/lib/files.js +60 -0
- package/dist/lib/gesture.d.ts +70 -0
- package/dist/lib/gesture.js +141 -0
- package/dist/lib/glide.d.ts +5 -0
- package/dist/lib/glide.js +9 -1
- package/dist/lib/icons.d.ts +1 -0
- package/dist/lib/icons.js +6 -0
- package/dist/lib/illustration-library.js +1 -6
- package/dist/lib/markdown-edit.d.ts +112 -0
- package/dist/lib/markdown-edit.js +557 -0
- package/dist/lib/markdown-rich-editor.d.ts +188 -0
- package/dist/lib/markdown-rich-editor.js +1153 -0
- package/dist/lib/markdown-rich.d.ts +63 -0
- package/dist/lib/markdown-rich.js +534 -0
- package/dist/lib/mentions.d.ts +100 -0
- package/dist/lib/mentions.js +246 -0
- package/dist/lib/motion.d.ts +18 -0
- package/dist/lib/motion.js +43 -5
- package/dist/lib/number-roll.d.ts +89 -0
- package/dist/lib/number-roll.js +391 -0
- package/dist/lib/platform.d.ts +6 -0
- package/dist/lib/platform.js +14 -0
- package/dist/lib/portal-container.d.ts +9 -0
- package/dist/lib/portal-container.js +10 -0
- package/dist/lib/press.d.ts +5 -0
- package/dist/lib/press.js +186 -0
- package/dist/lib/scheduler.d.ts +128 -0
- package/dist/lib/scheduler.js +272 -0
- package/dist/lib/scroll-edges.d.ts +9 -0
- package/dist/lib/scroll-edges.js +50 -0
- package/dist/lib/table-fit.d.ts +1 -1
- package/dist/lib/table-fit.js +65 -8
- package/dist/lib/theme-preset.d.ts +267 -0
- package/dist/lib/theme-preset.js +1046 -0
- package/dist/lib/theme-script.d.ts +23 -3
- package/dist/lib/theme-script.js +17 -5
- package/dist/lib/tippy/sprite.d.ts +36 -4
- package/dist/lib/tippy/sprite.js +188 -15
- package/dist/lib/tone.d.ts +4 -0
- package/dist/lib/tone.js +1 -0
- package/dist/messages/de.d.ts +3 -3
- package/dist/messages/de.js +274 -3
- package/dist/skills/zon-ui/SKILL.md +279 -0
- package/dist/skills/zon-ui/references/authoring.md +265 -0
- package/dist/skills/zon-ui/references/brand.md +416 -0
- package/dist/skills/zon-ui/references/components/accordion.md +199 -0
- package/dist/skills/zon-ui/references/components/action-sheet.md +268 -0
- package/dist/skills/zon-ui/references/components/alert-dialog.md +276 -0
- package/dist/skills/zon-ui/references/components/alert.md +167 -0
- package/dist/skills/zon-ui/references/components/app-bar.md +307 -0
- package/dist/skills/zon-ui/references/components/ascii-field.md +121 -0
- package/dist/skills/zon-ui/references/components/aspect-ratio.md +112 -0
- package/dist/skills/zon-ui/references/components/audio-player.md +231 -0
- package/dist/skills/zon-ui/references/components/avatar.md +98 -0
- package/dist/skills/zon-ui/references/components/badge.md +227 -0
- package/dist/skills/zon-ui/references/components/bottom-nav.md +709 -0
- package/dist/skills/zon-ui/references/components/breadcrumb.md +143 -0
- package/dist/skills/zon-ui/references/components/button-group.md +216 -0
- package/dist/skills/zon-ui/references/components/button.md +309 -0
- package/dist/skills/zon-ui/references/components/calendar.md +296 -0
- package/dist/skills/zon-ui/references/components/card.md +158 -0
- package/dist/skills/zon-ui/references/components/carousel.md +297 -0
- package/dist/skills/zon-ui/references/components/chart.md +739 -0
- package/dist/skills/zon-ui/references/components/chat.md +417 -0
- package/dist/skills/zon-ui/references/components/checkbox.md +219 -0
- package/dist/skills/zon-ui/references/components/code-block.md +143 -0
- package/dist/skills/zon-ui/references/components/code-highlight.md +118 -0
- package/dist/skills/zon-ui/references/components/collapsible.md +146 -0
- package/dist/skills/zon-ui/references/components/color-picker.md +200 -0
- package/dist/skills/zon-ui/references/components/combobox.md +455 -0
- package/dist/skills/zon-ui/references/components/command.md +326 -0
- package/dist/skills/zon-ui/references/components/contact-form.md +562 -0
- package/dist/skills/zon-ui/references/components/context-menu.md +159 -0
- package/dist/skills/zon-ui/references/components/conversation.md +146 -0
- package/dist/skills/zon-ui/references/components/copy-button.md +162 -0
- package/dist/skills/zon-ui/references/components/crm.md +1022 -0
- package/dist/skills/zon-ui/references/components/dashboard.md +612 -0
- package/dist/skills/zon-ui/references/components/data-table.md +776 -0
- package/dist/skills/zon-ui/references/components/date-picker.md +444 -0
- package/dist/skills/zon-ui/references/components/dialog.md +335 -0
- package/dist/skills/zon-ui/references/components/direction.md +165 -0
- package/dist/skills/zon-ui/references/components/drawer.md +276 -0
- package/dist/skills/zon-ui/references/components/drawing.md +94 -0
- package/dist/skills/zon-ui/references/components/empty.md +225 -0
- package/dist/skills/zon-ui/references/components/feature-list.md +412 -0
- package/dist/skills/zon-ui/references/components/field.md +209 -0
- package/dist/skills/zon-ui/references/components/file-drop.md +234 -0
- package/dist/skills/zon-ui/references/components/filter-bar.md +485 -0
- package/dist/skills/zon-ui/references/components/form.md +970 -0
- package/dist/skills/zon-ui/references/components/graph.md +339 -0
- package/dist/skills/zon-ui/references/components/illustration.md +497 -0
- package/dist/skills/zon-ui/references/components/inbox.md +263 -0
- package/dist/skills/zon-ui/references/components/input-group.md +339 -0
- package/dist/skills/zon-ui/references/components/input.md +189 -0
- package/dist/skills/zon-ui/references/components/item.md +277 -0
- package/dist/skills/zon-ui/references/components/kanban.md +626 -0
- package/dist/skills/zon-ui/references/components/kbd.md +116 -0
- package/dist/skills/zon-ui/references/components/label.md +104 -0
- package/dist/skills/zon-ui/references/components/layout.md +291 -0
- package/dist/skills/zon-ui/references/components/lightbox.md +235 -0
- package/dist/skills/zon-ui/references/components/locale.md +279 -0
- package/dist/skills/zon-ui/references/components/logo.md +257 -0
- package/dist/skills/zon-ui/references/components/markdown-editor.md +558 -0
- package/dist/skills/zon-ui/references/components/mentions.md +512 -0
- package/dist/skills/zon-ui/references/components/menu.md +218 -0
- package/dist/skills/zon-ui/references/components/menubar.md +292 -0
- package/dist/skills/zon-ui/references/components/message.md +243 -0
- package/dist/skills/zon-ui/references/components/meter.md +105 -0
- package/dist/skills/zon-ui/references/components/money-input.md +333 -0
- package/dist/skills/zon-ui/references/components/native-select.md +197 -0
- package/dist/skills/zon-ui/references/components/navigation-menu.md +253 -0
- package/dist/skills/zon-ui/references/components/number-field.md +210 -0
- package/dist/skills/zon-ui/references/components/number-roll.md +175 -0
- package/dist/skills/zon-ui/references/components/onboarding.md +896 -0
- package/dist/skills/zon-ui/references/components/otp-field.md +166 -0
- package/dist/skills/zon-ui/references/components/pagination.md +109 -0
- package/dist/skills/zon-ui/references/components/pdf-viewer.md +177 -0
- package/dist/skills/zon-ui/references/components/phone-input.md +252 -0
- package/dist/skills/zon-ui/references/components/popover.md +176 -0
- package/dist/skills/zon-ui/references/components/preview-card.md +193 -0
- package/dist/skills/zon-ui/references/components/pricing.md +724 -0
- package/dist/skills/zon-ui/references/components/progress.md +92 -0
- package/dist/skills/zon-ui/references/components/prompt-input.md +307 -0
- package/dist/skills/zon-ui/references/components/pull-to-refresh.md +188 -0
- package/dist/skills/zon-ui/references/components/quote.md +115 -0
- package/dist/skills/zon-ui/references/components/radio-group.md +215 -0
- package/dist/skills/zon-ui/references/components/rating.md +260 -0
- package/dist/skills/zon-ui/references/components/reasoning.md +102 -0
- package/dist/skills/zon-ui/references/components/resizable.md +213 -0
- package/dist/skills/zon-ui/references/components/response.md +170 -0
- package/dist/skills/zon-ui/references/components/scheduler.md +732 -0
- package/dist/skills/zon-ui/references/components/scroll-area.md +122 -0
- package/dist/skills/zon-ui/references/components/select.md +351 -0
- package/dist/skills/zon-ui/references/components/separator.md +103 -0
- package/dist/skills/zon-ui/references/components/settings.md +793 -0
- package/dist/skills/zon-ui/references/components/shop.md +1715 -0
- package/dist/skills/zon-ui/references/components/sidebar.md +813 -0
- package/dist/skills/zon-ui/references/components/sign-in.md +1639 -0
- package/dist/skills/zon-ui/references/components/site-header.md +303 -0
- package/dist/skills/zon-ui/references/components/skeleton.md +256 -0
- package/dist/skills/zon-ui/references/components/slider.md +172 -0
- package/dist/skills/zon-ui/references/components/sortable.md +405 -0
- package/dist/skills/zon-ui/references/components/sources.md +106 -0
- package/dist/skills/zon-ui/references/components/spinner.md +222 -0
- package/dist/skills/zon-ui/references/components/stat.md +267 -0
- package/dist/skills/zon-ui/references/components/stepper.md +285 -0
- package/dist/skills/zon-ui/references/components/suggestions.md +146 -0
- package/dist/skills/zon-ui/references/components/swipe-actions.md +344 -0
- package/dist/skills/zon-ui/references/components/switch.md +160 -0
- package/dist/skills/zon-ui/references/components/table.md +999 -0
- package/dist/skills/zon-ui/references/components/tabs.md +258 -0
- package/dist/skills/zon-ui/references/components/tag.md +115 -0
- package/dist/skills/zon-ui/references/components/tags-input.md +216 -0
- package/dist/skills/zon-ui/references/components/textarea.md +95 -0
- package/dist/skills/zon-ui/references/components/theme-editor.md +3940 -0
- package/dist/skills/zon-ui/references/components/theme.md +362 -0
- package/dist/skills/zon-ui/references/components/time-field.md +222 -0
- package/dist/skills/zon-ui/references/components/timeline.md +285 -0
- package/dist/skills/zon-ui/references/components/tippy.md +243 -0
- package/dist/skills/zon-ui/references/components/toast.md +220 -0
- package/dist/skills/zon-ui/references/components/toggle-group.md +261 -0
- package/dist/skills/zon-ui/references/components/toggle.md +167 -0
- package/dist/skills/zon-ui/references/components/tool-call.md +146 -0
- package/dist/skills/zon-ui/references/components/toolbar.md +260 -0
- package/dist/skills/zon-ui/references/components/tooltip.md +172 -0
- package/dist/skills/zon-ui/references/components/tour.md +423 -0
- package/dist/skills/zon-ui/references/components/tree.md +481 -0
- package/dist/skills/zon-ui/references/components/typography.md +347 -0
- package/dist/skills/zon-ui/references/components/video-player.md +386 -0
- package/dist/skills/zon-ui/references/marketing.md +467 -0
- package/dist/skills/zon-ui/references/motion.md +455 -0
- package/dist/skills/zon-ui/references/recipes.md +1232 -0
- package/dist/skills/zon-ui/references/tokens.md +866 -0
- package/dist/sources/accordion.css +4 -0
- package/dist/sources/action-sheet.css +11 -0
- package/dist/sources/alert-dialog.css +6 -0
- package/dist/sources/alert.css +3 -0
- package/dist/sources/app-bar.css +14 -0
- package/dist/sources/ascii-field.css +3 -0
- package/dist/sources/aspect-ratio.css +3 -0
- package/dist/sources/audio-player.css +20 -0
- package/dist/sources/avatar.css +3 -0
- package/dist/sources/badge.css +3 -0
- package/dist/sources/bottom-nav.css +9 -0
- package/dist/sources/breadcrumb.css +14 -0
- package/dist/sources/button-group.css +3 -0
- package/dist/sources/button.css +9 -0
- package/dist/sources/calendar.css +13 -0
- package/dist/sources/card.css +3 -0
- package/dist/sources/carousel.css +11 -0
- package/dist/sources/chart.css +5 -0
- package/dist/sources/checkbox.css +6 -0
- package/dist/sources/code-block.css +13 -0
- package/dist/sources/collapsible.css +4 -0
- package/dist/sources/color-picker.css +13 -0
- package/dist/sources/combobox.css +13 -0
- package/dist/sources/command.css +13 -0
- package/dist/sources/context-menu.css +12 -0
- package/dist/sources/conversation.css +10 -0
- package/dist/sources/copy-button.css +10 -0
- package/dist/sources/data-table.css +27 -0
- package/dist/sources/date-picker.css +20 -0
- package/dist/sources/dialog.css +9 -0
- package/dist/sources/direction.css +2 -0
- package/dist/sources/drawer.css +9 -0
- package/dist/sources/drawing.css +5 -0
- package/dist/sources/empty.css +3 -0
- package/dist/sources/feature-list.css +4 -0
- package/dist/sources/field.css +4 -0
- package/dist/sources/file-drop.css +15 -0
- package/dist/sources/filter-bar.css +30 -0
- package/dist/sources/form.css +4 -0
- package/dist/sources/graph.css +19 -0
- package/dist/sources/illustration.css +28 -0
- package/dist/sources/input-group.css +7 -0
- package/dist/sources/input.css +3 -0
- package/dist/sources/item.css +4 -0
- package/dist/sources/kbd.css +5 -0
- package/dist/sources/label.css +3 -0
- package/dist/sources/layout.css +3 -0
- package/dist/sources/lightbox.css +33 -0
- package/dist/sources/locale.css +2 -0
- package/dist/sources/logo.css +4 -0
- package/dist/sources/markdown-editor.css +41 -0
- package/dist/sources/mentions.css +13 -0
- package/dist/sources/menu.css +11 -0
- package/dist/sources/menubar.css +14 -0
- package/dist/sources/message.css +16 -0
- package/dist/sources/meter.css +4 -0
- package/dist/sources/money-input.css +10 -0
- package/dist/sources/native-select.css +4 -0
- package/dist/sources/navigation-menu.css +8 -0
- package/dist/sources/number-field.css +8 -0
- package/dist/sources/number-roll.css +6 -0
- package/dist/sources/otp-field.css +5 -0
- package/dist/sources/pagination.css +11 -0
- package/dist/sources/pdf-viewer.css +30 -0
- package/dist/sources/phone-input.css +20 -0
- package/dist/sources/popover.css +7 -0
- package/dist/sources/preview-card.css +7 -0
- package/dist/sources/progress.css +4 -0
- package/dist/sources/prompt-input.css +15 -0
- package/dist/sources/pull-to-refresh.css +14 -0
- package/dist/sources/quote.css +3 -0
- package/dist/sources/radio-group.css +5 -0
- package/dist/sources/rating.css +6 -0
- package/dist/sources/reasoning.css +6 -0
- package/dist/sources/resizable.css +4 -0
- package/dist/sources/response.css +16 -0
- package/dist/sources/scheduler.css +44 -0
- package/dist/sources/scroll-area.css +3 -0
- package/dist/sources/select.css +12 -0
- package/dist/sources/separator.css +3 -0
- package/dist/sources/sidebar.css +19 -0
- package/dist/sources/site-header.css +15 -0
- package/dist/sources/skeleton.css +3 -0
- package/dist/sources/slider.css +6 -0
- package/dist/sources/sortable.css +12 -0
- package/dist/sources/sources.css +6 -0
- package/dist/sources/spinner.css +6 -0
- package/dist/sources/stat.css +9 -0
- package/dist/sources/stepper.css +6 -0
- package/dist/sources/suggestions.css +10 -0
- package/dist/sources/swipe-actions.css +20 -0
- package/dist/sources/switch.css +5 -0
- package/dist/sources/table.css +7 -0
- package/dist/sources/tabs.css +5 -0
- package/dist/sources/tag.css +3 -0
- package/dist/sources/tags-input.css +6 -0
- package/dist/sources/textarea.css +3 -0
- package/dist/sources/theme.css +13 -0
- package/dist/sources/time-field.css +7 -0
- package/dist/sources/timeline.css +7 -0
- package/dist/sources/tippy.css +6 -0
- package/dist/sources/toast.css +6 -0
- package/dist/sources/toggle-group.css +5 -0
- package/dist/sources/toggle.css +3 -0
- package/dist/sources/tool-call.css +16 -0
- package/dist/sources/toolbar.css +14 -0
- package/dist/sources/tooltip.css +6 -0
- package/dist/sources/tour.css +14 -0
- package/dist/sources/tree.css +6 -0
- package/dist/sources/typography.css +4 -0
- package/dist/sources/video-player.css +21 -0
- package/dist/styles/ai.css +3 -0
- package/dist/styles/brand.css +98 -0
- package/dist/styles/core.css +266 -0
- package/dist/styles/editor.css +3 -0
- package/dist/styles/expressive.css +35 -56
- package/dist/styles/fonts.css +61 -117
- package/dist/styles/graph.css +4 -0
- package/dist/styles/illustration.css +4 -0
- package/dist/styles/index.css +11 -201
- package/dist/styles/material.css +138 -12
- package/dist/styles/parts/ai.css +18 -13
- package/dist/styles/parts/brand.css +2 -2
- package/dist/styles/parts/controls.css +29 -20
- package/dist/styles/parts/data.css +13 -9
- package/dist/styles/parts/editor.css +372 -0
- package/dist/styles/parts/feedback.css +32 -2
- package/dist/styles/parts/foundations.css +12 -7
- package/dist/styles/parts/graph.css +25 -9
- package/dist/styles/parts/inputs.css +172 -9
- package/dist/styles/parts/isometric.css +6 -5
- package/dist/styles/parts/navigation.css +206 -27
- package/dist/styles/parts/overlays.css +19 -4
- package/dist/styles/parts/pdf.css +2 -2
- package/dist/styles/pdf.css +3 -0
- package/dist/styles/prose.css +3 -0
- package/dist/styles/tokens.css +89 -14
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +5 -0
- package/dist/vite.d.ts +48 -59
- package/dist/vite.js +54 -21
- package/package.json +69 -2
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
# Markdown Editor
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
import { Button, Field, FieldLabel } from "@zonsh/ui";
|
|
5
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
export function Basic() {
|
|
9
|
+
const [comment, setComment] = React.useState("");
|
|
10
|
+
return (
|
|
11
|
+
<form
|
|
12
|
+
className="flex w-full max-w-xl flex-col gap-3"
|
|
13
|
+
onSubmit={(event) => {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
setComment("");
|
|
16
|
+
}}
|
|
17
|
+
>
|
|
18
|
+
<Field>
|
|
19
|
+
<FieldLabel>Comment</FieldLabel>
|
|
20
|
+
<MarkdownEditor
|
|
21
|
+
name="comment"
|
|
22
|
+
value={comment}
|
|
23
|
+
onValueChange={setComment}
|
|
24
|
+
placeholder="Review the change, ask a question, or suggest a fix"
|
|
25
|
+
/>
|
|
26
|
+
</Field>
|
|
27
|
+
<div className="flex justify-end">
|
|
28
|
+
<Button type="submit" disabled={!comment.trim()}>
|
|
29
|
+
Comment
|
|
30
|
+
</Button>
|
|
31
|
+
</div>
|
|
32
|
+
</form>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A recessed field for formatted text — a comment, a note, a ticket's description — stored as markdown. It writes like Notion and Slack: bold shows bold, no markdown marks show. `value` and `onValueChange` are markdown strings, so the text renders anywhere with `Response` and diffs cleanly.
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Its own entry, `@zonsh/ui/markdown-editor`, is built on [Tiptap](https://tiptap.dev), an optional peer — install its packages at one version. If you load styles in parts, add `styles/editor.css`.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm add @tiptap/core @tiptap/pm @tiptap/react @tiptap/starter-kit @tiptap/extension-list @tiptap/extensions @tiptap/markdown
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { Field, FieldLabel } from "@zonsh/ui";
|
|
49
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
50
|
+
|
|
51
|
+
<Field>
|
|
52
|
+
<FieldLabel>Comment</FieldLabel>
|
|
53
|
+
<MarkdownEditor name="comment" placeholder="Leave a comment" />
|
|
54
|
+
</Field>;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The props you'll reach for: `value` / `onValueChange` (or `name` to submit with the form), `placeholder`, and `toolbar` (`"top"`, `"bottom"`, `"none"`).
|
|
58
|
+
|
|
59
|
+
The toolbar holds the "Text ▾" block menu, marks, lists and blocks. Selecting text raises a bubble of marks; `/` opens a block menu; typed markdown (`**`, `- `, `# `, `> `, ```` ``` ````) turns into what it means. The field grows from `minRows` to `maxRows` lines, then scrolls.
|
|
60
|
+
|
|
61
|
+
## When to use
|
|
62
|
+
|
|
63
|
+
- Text people write and others read formatted: comments, messages, descriptions, notes, release notes.
|
|
64
|
+
- `mode="markdown"` for writers at home in markdown (a developer tool), or `modeToggle` to let each person switch.
|
|
65
|
+
- For a sentence or plain value, use `Input` or `Textarea`; for an AI chat prompt, `PromptInput`; for files alone, `FileDrop`.
|
|
66
|
+
|
|
67
|
+
## Examples
|
|
68
|
+
|
|
69
|
+
### Message composer
|
|
70
|
+
|
|
71
|
+
`toolbar="bottom"` and `submitOnEnter`: Enter sends, Shift+Enter breaks the line, Enter in a list or code block carries on, and ⌘Enter / Ctrl+Enter always sends. `mentions` takes `Mentions`-shaped triggers; a pick is a chip in the text and its name in the markdown.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { Button, Response } from "@zonsh/ui";
|
|
75
|
+
import { MarkdownEditor, type MarkdownEditorMentionOption, type MarkdownEditorMentionTrigger } from "@zonsh/ui/markdown-editor";
|
|
76
|
+
import { HashIcon, SendHorizontalIcon } from "lucide-react";
|
|
77
|
+
import * as React from "react";
|
|
78
|
+
|
|
79
|
+
const people: MarkdownEditorMentionOption[] = [
|
|
80
|
+
{ id: "u-ines", label: "Inés Moreau", description: "@ines" },
|
|
81
|
+
{ id: "u-tomasz", label: "Tomasz Wójcik", description: "@tomasz" },
|
|
82
|
+
{ id: "u-amara", label: "Amara Okafor", description: "@amara" },
|
|
83
|
+
{ id: "u-kenji", label: "Kenji Sato", description: "@kenji" },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const channels: MarkdownEditorMentionOption[] = [
|
|
87
|
+
{ id: "c-ceramics", label: "ceramics", icon: <HashIcon /> },
|
|
88
|
+
{ id: "c-glazes", label: "glazes", icon: <HashIcon /> },
|
|
89
|
+
{ id: "c-kiln-schedule", label: "kiln-schedule", icon: <HashIcon /> },
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
const triggers: MarkdownEditorMentionTrigger[] = [
|
|
93
|
+
{ char: "@", items: people, label: "People", allowSpaces: true },
|
|
94
|
+
{ char: "#", items: channels, label: "Channels", appearance: "text" },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
interface Message {
|
|
98
|
+
id: number;
|
|
99
|
+
author: string;
|
|
100
|
+
time: string;
|
|
101
|
+
text: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function MessageComposer() {
|
|
105
|
+
const [messages, setMessages] = React.useState<Message[]>([
|
|
106
|
+
{
|
|
107
|
+
id: 1,
|
|
108
|
+
author: "Amara Okafor",
|
|
109
|
+
time: "09:12",
|
|
110
|
+
text: "The **celadon** test tiles are out. Two crazed, the rest look even — photos in #glazes.",
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
const [draft, setDraft] = React.useState("");
|
|
114
|
+
const send = () => {
|
|
115
|
+
if (!draft.trim()) return;
|
|
116
|
+
setMessages((list) => [
|
|
117
|
+
...list,
|
|
118
|
+
{ id: list.length + 1, author: "Kenji Sato", time: "09:14", text: draft },
|
|
119
|
+
]);
|
|
120
|
+
setDraft("");
|
|
121
|
+
};
|
|
122
|
+
return (
|
|
123
|
+
<div className="flex w-full max-w-xl flex-col gap-4">
|
|
124
|
+
<ol aria-label="Messages in #ceramics" className="flex flex-col gap-4">
|
|
125
|
+
{messages.map((m) => (
|
|
126
|
+
<li key={m.id} className="flex flex-col gap-1">
|
|
127
|
+
<p className="flex items-baseline gap-2 text-sm">
|
|
128
|
+
<span className="font-medium text-foreground">{m.author}</span>
|
|
129
|
+
<span className="font-mono text-[11px] text-muted-foreground tabular-nums">{m.time}</span>
|
|
130
|
+
</p>
|
|
131
|
+
<Response smooth={false}>{m.text}</Response>
|
|
132
|
+
</li>
|
|
133
|
+
))}
|
|
134
|
+
</ol>
|
|
135
|
+
<form
|
|
136
|
+
className="flex items-end gap-2"
|
|
137
|
+
onSubmit={(event) => {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
send();
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<MarkdownEditor
|
|
143
|
+
aria-label="Message #ceramics"
|
|
144
|
+
placeholder="Message #ceramics"
|
|
145
|
+
value={draft}
|
|
146
|
+
onValueChange={setDraft}
|
|
147
|
+
submitOnEnter
|
|
148
|
+
mentions={triggers}
|
|
149
|
+
toolbar="bottom"
|
|
150
|
+
tools={[
|
|
151
|
+
"bold",
|
|
152
|
+
"italic",
|
|
153
|
+
"strikethrough",
|
|
154
|
+
"link",
|
|
155
|
+
"bulletList",
|
|
156
|
+
"numberedList",
|
|
157
|
+
"code",
|
|
158
|
+
"codeBlock",
|
|
159
|
+
]}
|
|
160
|
+
minRows={1}
|
|
161
|
+
maxRows={8}
|
|
162
|
+
/>
|
|
163
|
+
<Button type="submit" size="icon" aria-label="Send" disabled={!draft.trim()}>
|
|
164
|
+
<SendHorizontalIcon className="rtl:-scale-x-100" />
|
|
165
|
+
</Button>
|
|
166
|
+
</form>
|
|
167
|
+
<p className="text-[13px] text-muted-foreground">
|
|
168
|
+
Enter sends, Shift+Enter starts a new line. Type @ for people, # for channels.
|
|
169
|
+
</p>
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Document
|
|
176
|
+
|
|
177
|
+
`toolbar="none"`: formatting comes from "/", the selection bubble, typed markdown and shortcuts.
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
181
|
+
|
|
182
|
+
export function Document() {
|
|
183
|
+
return (
|
|
184
|
+
<div className="w-full max-w-2xl">
|
|
185
|
+
<MarkdownEditor
|
|
186
|
+
aria-label="Workshop plan"
|
|
187
|
+
toolbar="none"
|
|
188
|
+
minRows={10}
|
|
189
|
+
maxRows={30}
|
|
190
|
+
defaultValue={
|
|
191
|
+
"## Glaze workshop, Saturday\n\nTwo sessions in the studio, ten places each. Bring an apron and clothes that can take a splash.\n\n### Before\n\n- [x] Order test tiles\n- [ ] Mix the celadon and the tenmoku\n- [ ] Book the kiln for Sunday night\n\n> Glazes look nothing like their fired colour. Label every bucket."
|
|
192
|
+
}
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Tables
|
|
200
|
+
|
|
201
|
+
GFM tables, one line per cell. The table button or `/table` inserts three columns; Tab and Shift+Tab move between cells (Tab in the last adds a row), Enter moves down. A "Table ▾" button adds or deletes rows and columns, or the table. Lists, headings and quotes are off inside a cell.
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import { Field, FieldDescription, FieldLabel } from "@zonsh/ui";
|
|
205
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
206
|
+
|
|
207
|
+
export function Tables() {
|
|
208
|
+
return (
|
|
209
|
+
<Field className="w-full max-w-xl">
|
|
210
|
+
<FieldLabel>Firing log</FieldLabel>
|
|
211
|
+
<MarkdownEditor
|
|
212
|
+
minRows={8}
|
|
213
|
+
maxRows={20}
|
|
214
|
+
defaultValue={
|
|
215
|
+
"Bisque and glaze firings for the spring term.\n\n| Firing | Cone | Kiln | Done |\n| --- | :---: | --- | --- |\n| Bisque | 04 | Small electric | Yes |\n| Celadon | 10 | Gas | No |\n\nLog each firing on the day it is unloaded."
|
|
216
|
+
}
|
|
217
|
+
/>
|
|
218
|
+
<FieldDescription>Tab moves to the next cell; Tab in the last cell adds a row.</FieldDescription>
|
|
219
|
+
</Field>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### With attachments
|
|
225
|
+
|
|
226
|
+
Set `files`, `defaultFiles`, `onFilesChange` or `upload` to take files pasted (a screenshot arrives as an image), dropped or picked with the paperclip. `accept`, `maxSize` and `maxFiles` check them as `FileDrop` does; `onFileReject` hears why one was refused. Text copied from a spreadsheet or word processor still pastes as text.
|
|
227
|
+
|
|
228
|
+
Without `upload`, files are staged below the text (images as thumbnails, others as a row with a mono size) and sent with the form. With `upload`, "Uploading shot.png…" stands at the caret (`![Uploading shot.png…]()`) until the resolved markdown (``) replaces it. Resolving to nothing keeps the file staged; a failure is marked below the text.
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
import { Field, FieldDescription, FieldLabel, toast, type FileDropRejection } from "@zonsh/ui";
|
|
232
|
+
import { MarkdownEditor, type MarkdownEditorMentionOption } from "@zonsh/ui/markdown-editor";
|
|
233
|
+
import * as React from "react";
|
|
234
|
+
|
|
235
|
+
// people: as in the first example on this page that uses them.
|
|
236
|
+
|
|
237
|
+
/** Stands in for a real upload: an image comes back as markdown after a moment, anything else stays attached. */
|
|
238
|
+
function uploadFile(file: File) {
|
|
239
|
+
return new Promise<string | null>((resolve) =>
|
|
240
|
+
setTimeout(
|
|
241
|
+
() => resolve(file.type.startsWith("image/") ? `})` : null),
|
|
242
|
+
900,
|
|
243
|
+
),
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const MB = 1024 * 1024;
|
|
248
|
+
|
|
249
|
+
export function TicketDescription() {
|
|
250
|
+
const [files, setFiles] = React.useState<File[]>(() => [
|
|
251
|
+
new File(["Shelf, 120 × 40 cm, oak veneer"], "cutting-list.csv", { type: "text/csv" }),
|
|
252
|
+
]);
|
|
253
|
+
return (
|
|
254
|
+
<Field className="w-full max-w-xl">
|
|
255
|
+
<FieldLabel>Description</FieldLabel>
|
|
256
|
+
<MarkdownEditor
|
|
257
|
+
defaultValue={
|
|
258
|
+
"The shelf brackets in the assembly guide don't match the parts in the box.\n\n### What I checked\n\n- [x] The parts list against the box\n- [ ] A photo of the brackets\n\nThe guide shows **L-shaped** brackets; the box has flat plates marked `B-14`."
|
|
259
|
+
}
|
|
260
|
+
minRows={6}
|
|
261
|
+
maxRows={16}
|
|
262
|
+
files={files}
|
|
263
|
+
onFilesChange={setFiles}
|
|
264
|
+
upload={uploadFile}
|
|
265
|
+
maxSize={10 * MB}
|
|
266
|
+
mentions={[{ char: "@", items: people, label: "People", allowSpaces: true }]}
|
|
267
|
+
onFileReject={(rejected: FileDropRejection[]) =>
|
|
268
|
+
toast.error(`${rejected[0]!.file.name} is over 10 MB`, {
|
|
269
|
+
description: "Attach a smaller file, or a link to it.",
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
/>
|
|
273
|
+
<FieldDescription>
|
|
274
|
+
Paste, drop or attach files. Images go into the text; other files are attached to the ticket.
|
|
275
|
+
</FieldDescription>
|
|
276
|
+
</Field>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Markdown view
|
|
282
|
+
|
|
283
|
+
`mode="markdown"` is a textarea: the toolbar types the marks, Enter continues and renumbers a list, Tab nests it, and a URL pasted over a selection links it. `preview` adds Write and Preview tabs, rendered with `Response` at the text's height so nothing jumps.
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { Field, FieldLabel } from "@zonsh/ui";
|
|
287
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
288
|
+
|
|
289
|
+
export function MarkdownMode() {
|
|
290
|
+
return (
|
|
291
|
+
<Field className="w-full max-w-xl">
|
|
292
|
+
<FieldLabel>Reading notes</FieldLabel>
|
|
293
|
+
<MarkdownEditor
|
|
294
|
+
mode="markdown"
|
|
295
|
+
preview
|
|
296
|
+
minRows={6}
|
|
297
|
+
defaultValue={
|
|
298
|
+
"### Week 3: Typography\n\nRead **chapters 4 and 5** before Thursday. Bring one question about _measure_, the length of a line.\n\n1. Set a paragraph at 45, 66 and 90 characters\n2. Compare them on a phone\n\n> The reader should not notice the type."
|
|
299
|
+
}
|
|
300
|
+
/>
|
|
301
|
+
</Field>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Switching views
|
|
307
|
+
|
|
308
|
+
`modeToggle` adds an MD toggle that switches views, keeping value and focus; `mode` / `onModeChange` remember each person's choice.
|
|
309
|
+
|
|
310
|
+
```tsx
|
|
311
|
+
import { Field, FieldDescription, FieldLabel } from "@zonsh/ui";
|
|
312
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
313
|
+
import * as React from "react";
|
|
314
|
+
|
|
315
|
+
export function SwitchViews() {
|
|
316
|
+
const [notes, setNotes] = React.useState(
|
|
317
|
+
"Release **2.4** moves exports to the _Share_ menu.\n\n- CSV and JSON stay\n- PDF export is new",
|
|
318
|
+
);
|
|
319
|
+
return (
|
|
320
|
+
<Field className="w-full max-w-xl">
|
|
321
|
+
<FieldLabel>Release note</FieldLabel>
|
|
322
|
+
<MarkdownEditor value={notes} onValueChange={setNotes} modeToggle minRows={4} />
|
|
323
|
+
<FieldDescription>MD, at the end of the toolbar, shows the markdown that is saved.</FieldDescription>
|
|
324
|
+
</Field>
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Fewer tools
|
|
330
|
+
|
|
331
|
+
`tools` picks commands and order (`heading` is the block menu, `divider` a rule button); `tools={[]}` hides the toolbar. Shortcuts always work.
|
|
332
|
+
|
|
333
|
+
```tsx
|
|
334
|
+
import { Field, FieldLabel } from "@zonsh/ui";
|
|
335
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
336
|
+
|
|
337
|
+
export function Tools() {
|
|
338
|
+
return (
|
|
339
|
+
<Field className="w-full max-w-xl">
|
|
340
|
+
<FieldLabel>Release note</FieldLabel>
|
|
341
|
+
<MarkdownEditor
|
|
342
|
+
tools={["bold", "italic", "code", "link", "bulletList"]}
|
|
343
|
+
minRows={2}
|
|
344
|
+
maxRows={6}
|
|
345
|
+
placeholder="What changed, in a sentence or two"
|
|
346
|
+
/>
|
|
347
|
+
</Field>
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Markdown shortcuts
|
|
353
|
+
|
|
354
|
+
`markdownShortcuts={false}` leaves typed markdown as typed — for text where `#`, `*` and `-` mean themselves, like a recipe. The toolbar, menus, "/" and pasted markdown still format, and a typed URL still links.
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { Field, FieldDescription, FieldLabel, Label, Switch } from "@zonsh/ui";
|
|
358
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
359
|
+
import * as React from "react";
|
|
360
|
+
|
|
361
|
+
export function MarkdownShortcuts() {
|
|
362
|
+
const [on, setOn] = React.useState(false);
|
|
363
|
+
return (
|
|
364
|
+
<div className="flex w-full max-w-xl flex-col gap-3">
|
|
365
|
+
<Label className="self-start">
|
|
366
|
+
<Switch checked={on} onCheckedChange={setOn} />
|
|
367
|
+
Markdown shortcuts
|
|
368
|
+
</Label>
|
|
369
|
+
<Field>
|
|
370
|
+
<FieldLabel>Recipe note</FieldLabel>
|
|
371
|
+
<MarkdownEditor
|
|
372
|
+
markdownShortcuts={on}
|
|
373
|
+
minRows={3}
|
|
374
|
+
placeholder="Try # Title, - item or **bold**"
|
|
375
|
+
defaultValue="Bake at 220 °C for the first 20 minutes, then # 2 rack, lid off."
|
|
376
|
+
/>
|
|
377
|
+
<FieldDescription>
|
|
378
|
+
Off, what you type stays as typed — a # or a * is just a character. The toolbar, “/” and pasted
|
|
379
|
+
markdown still format.
|
|
380
|
+
</FieldDescription>
|
|
381
|
+
</Field>
|
|
382
|
+
</div>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### States
|
|
388
|
+
|
|
389
|
+
A `Field` gives it label, description, error and the invalid edge. `name` submits the markdown; `required` asks for some. `disabled` dims it and turns the toolbar off; `readOnly` drops the toolbar; `maxLength` refuses typing and pasting past the limit.
|
|
390
|
+
|
|
391
|
+
```tsx
|
|
392
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "@zonsh/ui";
|
|
393
|
+
import { MarkdownEditor } from "@zonsh/ui/markdown-editor";
|
|
394
|
+
import * as React from "react";
|
|
395
|
+
|
|
396
|
+
export function States() {
|
|
397
|
+
const [text, setText] = React.useState("Fix");
|
|
398
|
+
const short = text.trim().length < 20;
|
|
399
|
+
return (
|
|
400
|
+
// Two columns when the demo itself is wide enough, so a phone-width frame stacks them.
|
|
401
|
+
<div className="@container w-full max-w-3xl">
|
|
402
|
+
<div className="grid gap-6 @xl:grid-cols-2">
|
|
403
|
+
<Field invalid={short}>
|
|
404
|
+
<FieldLabel>Steps to reproduce</FieldLabel>
|
|
405
|
+
<MarkdownEditor value={text} onValueChange={setText} minRows={3} maxLength={2000} />
|
|
406
|
+
{short ? (
|
|
407
|
+
<FieldError match>Write at least 20 characters, so someone else can follow the steps.</FieldError>
|
|
408
|
+
) : (
|
|
409
|
+
<FieldDescription>A numbered list is easiest to follow.</FieldDescription>
|
|
410
|
+
)}
|
|
411
|
+
</Field>
|
|
412
|
+
<Field disabled>
|
|
413
|
+
<FieldLabel>Description</FieldLabel>
|
|
414
|
+
<MarkdownEditor defaultValue="Locked while the ticket is **in review**." minRows={3} />
|
|
415
|
+
<FieldDescription>Editing opens again when the review is done.</FieldDescription>
|
|
416
|
+
</Field>
|
|
417
|
+
<Field>
|
|
418
|
+
<FieldLabel>Acceptance criteria</FieldLabel>
|
|
419
|
+
<MarkdownEditor
|
|
420
|
+
readOnly
|
|
421
|
+
minRows={2}
|
|
422
|
+
defaultValue={"- [x] Brackets match the guide\n- [ ] The guide is reprinted with **flat plates**"}
|
|
423
|
+
/>
|
|
424
|
+
<FieldDescription>Set by the product owner.</FieldDescription>
|
|
425
|
+
</Field>
|
|
426
|
+
<Field>
|
|
427
|
+
<FieldLabel>Summary</FieldLabel>
|
|
428
|
+
<MarkdownEditor minRows={2} placeholder="One or two sentences for the release notes" />
|
|
429
|
+
</Field>
|
|
430
|
+
</div>
|
|
431
|
+
</div>
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Writing
|
|
437
|
+
|
|
438
|
+
Toolbar buttons are flat 30px `ToolbarButton`s (38px on touch) that rise when on at the caret; tooltips show the shortcut for the device. The "Text ▾" menu names the line: in a line of text, a pick starts a new line of that kind below; with a selection or on an empty line, it converts those lines. List, quote and code-block buttons toggle. The row never scrolls — divider, table, code block, quote, to-do and numbered lists, code, strikethrough and more fold one by one into a "…" menu.
|
|
439
|
+
|
|
440
|
+
The text is compact: Licht Sans 14px at 1.5 (16px on touch, to avoid zoom), blocks 6px apart, headings in Licht Light 20 and 17px then Licht Sans semibold 15px, mono inline code on a raised key, en-dash list markers, `Checkbox`-style task boxes, hairline-grid tables.
|
|
441
|
+
|
|
442
|
+
- **The bubble.** A selection raises the marks over it in the menu material. It never takes focus; Alt+F10 moves into it.
|
|
443
|
+
- **"/".** At a line's start or after a space: Text, Heading 1–3, the lists, Quote, Code block, Table, Divider, and Attach files when files are on. What follows filters it ("/h2"); Escape leaves the "/" as text. An empty line hints "Type / for commands"; an empty heading names its level.
|
|
444
|
+
- **Markdown as you type.** Inline marks on their closing character; `- `, `1. `, `[ ] `, `> `, `# `–`#### ` and ```` ``` ```` at a line's start; `[text](url)` and bare URLs link. Backspace right after undoes the conversion.
|
|
445
|
+
- **Links.** ⌘K, the link button or a click opens a popover to edit, open or remove one. Text typed at a link's end is plain.
|
|
446
|
+
- **Images.** Sit in the line; a click picks one and opens a popover to edit its alt text or remove it.
|
|
447
|
+
- **Blocks.** Backspace at the start of a heading, quote, code block or list item first removes its formatting, then joins lines.
|
|
448
|
+
- **Paste.** Rich text is cleaned to what markdown can hold; pasted markdown is read as markdown.
|
|
449
|
+
- ⌘Z / Ctrl+Z undoes any of it; ⇧⌘Z / Ctrl+Y redoes.
|
|
450
|
+
|
|
451
|
+
## Props
|
|
452
|
+
|
|
453
|
+
| Prop | Type | Default |
|
|
454
|
+
| ------------------------ | --------------------------------------------------------------------- | ---------- |
|
|
455
|
+
| `value` / `defaultValue` | `string`: markdown | `""` |
|
|
456
|
+
| `onValueChange` | `(value: string) => void`: markdown | — |
|
|
457
|
+
| `mode` / `defaultMode` | `"rich" \| "markdown"`: the formatted text, or its markdown | `"rich"` |
|
|
458
|
+
| `onModeChange` | `(mode) => void` | — |
|
|
459
|
+
| `modeToggle` | `boolean`: an MD toggle at the end of the toolbar | `false` |
|
|
460
|
+
| `minRows` / `maxRows` | `number`: the height it starts at and grows to, in lines | `3` / `12` |
|
|
461
|
+
| `tools` | `MarkdownEditorCommand[]`: the toolbar's commands, in order; `heading` is the block menu, `table` inserts a table | all but `divider` |
|
|
462
|
+
| `toolbar` | `"top" \| "bottom" \| "none"`: where the formatting row sits | `"top"` |
|
|
463
|
+
| `slashCommands` | `boolean`: "/" opens the menu of blocks, and an empty line hints at it | `true` |
|
|
464
|
+
| `markdownShortcuts` | `boolean`: markdown typed as you go turns into what it means | `true` |
|
|
465
|
+
| `mentions` | `MarkdownEditorMentionTrigger[]`: the rich view's `@` and `#` triggers | — |
|
|
466
|
+
| `submitOnEnter` | `boolean`: Enter submits the form, Shift+Enter breaks the line | `false` |
|
|
467
|
+
| `preview` | `boolean`: Write and Preview tabs, in the markdown view | `false` |
|
|
468
|
+
| `files` / `defaultFiles` | `File[]`: the staged files | `[]` |
|
|
469
|
+
| `onFilesChange` | `(files: File[]) => void` | — |
|
|
470
|
+
| `upload` | `(file: File) => Promise<string \| null \| undefined \| void>` | — |
|
|
471
|
+
| `accept` | `string`, as on a file input: `"image/*,.pdf"` | any file |
|
|
472
|
+
| `maxSize` | `number`: bytes per file | — |
|
|
473
|
+
| `maxFiles` | `number`: files staged at once | — |
|
|
474
|
+
| `onFileReject` | `(rejected: { file, reason: "type" \| "size" \| "count" }[]) => void` | — |
|
|
475
|
+
| `ref` | `MarkdownEditorHandle`: `focus()`, `run(command)`, `insertText(text)`, `editor`, `textarea` | — |
|
|
476
|
+
| `textareaRef` | `Ref<HTMLTextAreaElement>`: the markdown view's textarea | — |
|
|
477
|
+
| `children` | parts that work with the editor, such as a mention menu | — |
|
|
478
|
+
| `labels` | `Partial<MarkdownEditorMessages>` | English |
|
|
479
|
+
| `disabled` | `boolean` | `false` |
|
|
480
|
+
| `readOnly` | `boolean`: formatted and selectable, without the toolbar | `false` |
|
|
481
|
+
| `maxLength` | `number`: characters of text (in the markdown view, of markdown) | — |
|
|
482
|
+
| `className` | `string`: the visible field | — |
|
|
483
|
+
|
|
484
|
+
`id`, `name`, `form`, `placeholder`, `required`, `autoFocus`, `aria-label`, `aria-labelledby`, `aria-describedby`, `onFocus`, `onBlur`, `onKeyDown` and `onPaste` go to the text (the contenteditable, or the markdown view's textarea); `style` goes to the writing area. Your `onKeyDown` and `onPaste` run first — `event.preventDefault()` stops the editor acting. A form reset restores an uncontrolled editor's `defaultValue` and `defaultFiles`. Data attributes on the field: `data-mode` (`rich` or `markdown`), `data-tab` (`write` or `preview`), `data-dragging`, `data-disabled`, `data-readonly`. A `LocaleProvider` sets `labels` for every editor (`messages.markdownEditor`), German included.
|
|
485
|
+
|
|
486
|
+
### Mention triggers
|
|
487
|
+
|
|
488
|
+
Each trigger is shaped like a `Mentions` trigger: `char`, `items` (a list, or a possibly async function with `debounce`), `itemToString`, `itemToKey`, `renderItem`, `label`, `empty`, `allowSpaces`, `maxLength`, `limit` and `onSelect`, with the same keys. A pick is a mention node drawn as Mentions draws one (`<span data-slot="mention" data-appearance="chip" data-tone="violet" data-trigger="@">`). A trigger adds:
|
|
489
|
+
|
|
490
|
+
| Prop | Type | Default |
|
|
491
|
+
| -------------- | ------------------------------------------------------------ | -------------------------- |
|
|
492
|
+
| `toMarkdown` | `(item) => string`: what the mention is written as | `"@" + itemToString(item)` |
|
|
493
|
+
| `fromMarkdown` | `(text) => { item, length } \| null`: read written ones back | a list's own items |
|
|
494
|
+
| `appearance` | `"chip" \| "text"` | `"chip"` |
|
|
495
|
+
| `tone` | a category tone, or `(item) => tone` | — |
|
|
496
|
+
|
|
497
|
+
Incoming markdown (value, paste, switch from the markdown view) turns mentions back into chips: with a list, by each item's `toMarkdown` text, longest first; with a function, by `fromMarkdown` (`[@ada](/u/ada)`, `<@U123>`). In the markdown view, host `Mentions` on the textarea, as below.
|
|
498
|
+
|
|
499
|
+
### What the markdown holds
|
|
500
|
+
|
|
501
|
+
The rich view reads and writes paragraphs, headings 1–4, bold, italic, strikethrough, inline code, links, quotes, bulleted, numbered and nested task lists, code blocks with their language, rules, line breaks, images with alt text, GFM tables with column alignment, and mentions — via [@tiptap/markdown](https://tiptap.dev/docs/editor/markdown), and tables on prosemirror-tables (in `@tiptap/pm`). Other spellings are normalised (`_a_` → `*a*`, `* item` → `- item`, unpadded cells), markdown characters are escaped (`2 \* 3`), and HTML is read as its formatting; anything else is dropped.
|
|
502
|
+
|
|
503
|
+
### Parts in `children`
|
|
504
|
+
|
|
505
|
+
`children` render beside the text and reach the editor through `useMarkdownEditor()`: `mode`, `value`, `disabled`, `readOnly`, `run(command)` and `insertText(text)`; in the rich view the Tiptap `editor`, in the markdown view `textareaRef` and `replaceRange(from, to, text)` — edits that keep the undo history. In the markdown view, pass the same ref to `Mentions` and the editor; Mentions then handles Enter, Tab and the arrows before the editor does.
|
|
506
|
+
|
|
507
|
+
```tsx
|
|
508
|
+
const ref = React.useRef<HTMLTextAreaElement>(null);
|
|
509
|
+
|
|
510
|
+
<MarkdownEditor mode="markdown" textareaRef={ref}>
|
|
511
|
+
<Mentions inputRef={ref} triggers={triggers} />
|
|
512
|
+
</MarkdownEditor>;
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## Brand rules
|
|
516
|
+
|
|
517
|
+
- **Do** keep the one primary action — Comment, Send, Create ticket — as a `Button` beside or under the field, never in the toolbar row; that row is for formatting.
|
|
518
|
+
- **Do** pick one place for formatting: the top row for a form field, under the text for a chat composer, none for long-form writing. The bubble and "/" are there in all three.
|
|
519
|
+
- **Do** tell people in a description what happens to a file they add.
|
|
520
|
+
- **Do** store and send the markdown. It renders with `Response`, in an email and in a diff.
|
|
521
|
+
- **Don't** colour the toolbar or the text. Commands are flat and muted; a mention's tone is the one colour, for kinds people must tell apart, and an error takes the destructive ink, with words.
|
|
522
|
+
|
|
523
|
+
## Accessibility
|
|
524
|
+
|
|
525
|
+
- The text is a `textbox` with `aria-multiline`, labelled by the `FieldLabel`, described by the `FieldDescription` and `FieldError`, and `aria-invalid` with the Field; clicking the label puts the caret in it.
|
|
526
|
+
- The toolbar is one tab stop before the text (after it with `toolbar="bottom"`), arrows inside. Buttons are named ("Bold"), carry `aria-keyshortcuts` and `aria-pressed`, keep the selection and return focus. The block menu is named for the line ("Turn into: Heading 2") with radio items.
|
|
527
|
+
- The selection bubble never takes focus by itself: Alt+F10 enters it, the arrows move along it, Escape returns to the text (Escape in the text closes it).
|
|
528
|
+
- The slash menu is a `listbox` named "Blocks", pointed at from the text like the mention list; a polite status says how many blocks match.
|
|
529
|
+
- Tab nests only in a list; elsewhere, and after Escape, Tab moves focus on, so the keyboard is never trapped.
|
|
530
|
+
- The mention list is a `listbox` the text points at with `aria-controls` and `aria-activedescendant`; a polite status says how many suggestions there are, or that they are loading.
|
|
531
|
+
- The link popover has a labelled field; Enter applies, Escape closes and returns focus to the text.
|
|
532
|
+
- Enter during IME composition picks its characters; it doesn't continue a list or send.
|
|
533
|
+
- An uploading file is read out by its spinner ("Uploading shot.png…"); a failed one says so in words beside a warning icon. Each staged file's remove button is named "Remove {name}".
|
|
534
|
+
- A table is a `table` with header cells; its menu button is named "Table" and never takes focus by itself — Alt+F10 moves to it. A picked image's popover has a labelled "Alt text" field.
|
|
535
|
+
- Read only, the text is a `textbox` with `aria-readonly`, selectable, its links and task boxes still read as they are.
|
|
536
|
+
|
|
537
|
+
### Keyboard
|
|
538
|
+
|
|
539
|
+
On Windows and Linux ⌘ is Ctrl (Ctrl+Shift for the shifted ones); on a Mac, Ctrl+B and Ctrl+K still move the caret. Both views have the same shortcuts.
|
|
540
|
+
|
|
541
|
+
| Key | Does |
|
|
542
|
+
| -------------------------- | ------------------------------------------------------------------- |
|
|
543
|
+
| ⌘B / ⌘I / ⇧⌘X / ⌘E | Bold, italic, strikethrough, code |
|
|
544
|
+
| ⌘K | Opens the link popover; Enter applies, Escape goes back |
|
|
545
|
+
| ⇧⌘8 / ⇧⌘7 / ⇧⌘9 | Bulleted, numbered, to-do list |
|
|
546
|
+
| ⇧⌘. | Quote |
|
|
547
|
+
| `/` | The menu of blocks: ↑ ↓ move, Enter or Tab picks, Escape closes |
|
|
548
|
+
| Tab / Shift+Tab | In a list, nests the item or moves it out; in a table, the next or the previous cell (Tab in the last adds a row); elsewhere, and after Escape, moves focus on |
|
|
549
|
+
| Enter | In a list, the next item; in a table, the cell below; on a picked image, into its alt text |
|
|
550
|
+
| Alt+F10 | Into the bubble over a selection, or the table's menu |
|
|
551
|
+
| Escape | Closes the bubble, a menu or a popover, back to the text |
|
|
552
|
+
| ⌘Enter | Submits the form; Enter alone with `submitOnEnter` |
|
|
553
|
+
| ⌘Z / ⇧⌘Z | Undo, redo |
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
- Import: `import { MarkdownEditor, useMarkdownEditor } from "@zonsh/ui/markdown-editor"`
|
|
558
|
+
- Source: `packages/ui/src/components/markdown-editor.tsx`
|