@atmos.build/ui 0.1.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 +45 -0
- package/dist/components/alert-dialog.d.ts +14 -0
- package/dist/components/alert-dialog.js +40 -0
- package/dist/components/at-search.d.ts +35 -0
- package/dist/components/at-search.js +57 -0
- package/dist/components/attachment-thumbnail-stack.d.ts +13 -0
- package/dist/components/attachment-thumbnail-stack.js +23 -0
- package/dist/components/audio-preview.d.ts +33 -0
- package/dist/components/audio-preview.js +176 -0
- package/dist/components/avatar-uploader.d.ts +29 -0
- package/dist/components/avatar-uploader.js +67 -0
- package/dist/components/avatar.d.ts +12 -0
- package/dist/components/avatar.js +38 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +25 -0
- package/dist/components/button-group.d.ts +12 -0
- package/dist/components/button-group.js +29 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +42 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +154 -0
- package/dist/components/channel-list.d.ts +33 -0
- package/dist/components/channel-list.js +40 -0
- package/dist/components/charts/area-chart.d.ts +2 -0
- package/dist/components/charts/area-chart.js +5 -0
- package/dist/components/charts/bar-chart.d.ts +2 -0
- package/dist/components/charts/bar-chart.js +58 -0
- package/dist/components/charts/colors.d.ts +2 -0
- package/dist/components/charts/colors.js +42 -0
- package/dist/components/charts/hover.d.ts +20 -0
- package/dist/components/charts/hover.js +31 -0
- package/dist/components/charts/index.d.ts +10 -0
- package/dist/components/charts/index.js +9 -0
- package/dist/components/charts/layout.d.ts +35 -0
- package/dist/components/charts/layout.js +101 -0
- package/dist/components/charts/legend.d.ts +6 -0
- package/dist/components/charts/legend.js +7 -0
- package/dist/components/charts/line-area-chart.d.ts +4 -0
- package/dist/components/charts/line-area-chart.js +86 -0
- package/dist/components/charts/line-chart.d.ts +2 -0
- package/dist/components/charts/line-chart.js +5 -0
- package/dist/components/charts/pie-chart.d.ts +2 -0
- package/dist/components/charts/pie-chart.js +22 -0
- package/dist/components/charts/radar-chart.d.ts +2 -0
- package/dist/components/charts/radar-chart.js +29 -0
- package/dist/components/charts/radial-chart.d.ts +2 -0
- package/dist/components/charts/radial-chart.js +19 -0
- package/dist/components/charts/scatter-chart.d.ts +2 -0
- package/dist/components/charts/scatter-chart.js +16 -0
- package/dist/components/charts/story-data.d.ts +24 -0
- package/dist/components/charts/story-data.js +48 -0
- package/dist/components/charts/types.d.ts +43 -0
- package/dist/components/charts/types.js +1 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/checkbox.js +10 -0
- package/dist/components/chip.d.ts +25 -0
- package/dist/components/chip.js +36 -0
- package/dist/components/code-editor-theme.d.ts +19 -0
- package/dist/components/code-editor-theme.js +100 -0
- package/dist/components/collapsible-section-header.d.ts +82 -0
- package/dist/components/collapsible-section-header.js +82 -0
- package/dist/components/collection-view/collection-view-group-settings.d.ts +73 -0
- package/dist/components/collection-view/collection-view-group-settings.js +55 -0
- package/dist/components/collection-view/collection-view-settings.d.ts +115 -0
- package/dist/components/collection-view/collection-view-settings.js +146 -0
- package/dist/components/collection-view/collection-view.d.ts +87 -0
- package/dist/components/collection-view/collection-view.js +95 -0
- package/dist/components/collection-view/index.d.ts +6 -0
- package/dist/components/collection-view/index.js +6 -0
- package/dist/components/collection-view/use-collection-detail-navigation.d.ts +11 -0
- package/dist/components/collection-view/use-collection-detail-navigation.js +12 -0
- package/dist/components/collection-view/use-collection-escape.d.ts +9 -0
- package/dist/components/collection-view/use-collection-escape.js +20 -0
- package/dist/components/collection-view/use-collection-selection.d.ts +42 -0
- package/dist/components/collection-view/use-collection-selection.js +203 -0
- package/dist/components/color-picker.d.ts +18 -0
- package/dist/components/color-picker.js +77 -0
- package/dist/components/color-swatch-list.d.ts +16 -0
- package/dist/components/color-swatch-list.js +60 -0
- package/dist/components/combobox/combobox.d.ts +4 -0
- package/dist/components/combobox/combobox.js +70 -0
- package/dist/components/combobox/compound.d.ts +68 -0
- package/dist/components/combobox/compound.js +151 -0
- package/dist/components/combobox/context.d.ts +34 -0
- package/dist/components/combobox/context.js +123 -0
- package/dist/components/combobox/create-step.d.ts +12 -0
- package/dist/components/combobox/create-step.js +8 -0
- package/dist/components/combobox/index.d.ts +10 -0
- package/dist/components/combobox/index.js +5 -0
- package/dist/components/combobox/inline-create-form.d.ts +24 -0
- package/dist/components/combobox/inline-create-form.js +43 -0
- package/dist/components/combobox/types.d.ts +57 -0
- package/dist/components/combobox/types.js +10 -0
- package/dist/components/command.d.ts +35 -0
- package/dist/components/command.js +76 -0
- package/dist/components/comment-pin.d.ts +13 -0
- package/dist/components/comment-pin.js +33 -0
- package/dist/components/confidence-meter.d.ts +11 -0
- package/dist/components/confidence-meter.js +24 -0
- package/dist/components/context-menu.d.ts +31 -0
- package/dist/components/context-menu.js +54 -0
- package/dist/components/copy-button.d.ts +12 -0
- package/dist/components/copy-button.js +32 -0
- package/dist/components/date-picker.d.ts +29 -0
- package/dist/components/date-picker.js +86 -0
- package/dist/components/date-tile.d.ts +11 -0
- package/dist/components/date-tile.js +16 -0
- package/dist/components/date-time-picker.d.ts +25 -0
- package/dist/components/date-time-picker.js +153 -0
- package/dist/components/detail-breadcrumb-utils.d.ts +2 -0
- package/dist/components/detail-breadcrumb-utils.js +18 -0
- package/dist/components/detail-nav-bar.d.ts +28 -0
- package/dist/components/detail-nav-bar.js +28 -0
- package/dist/components/detail-top-bar.d.ts +49 -0
- package/dist/components/detail-top-bar.js +41 -0
- package/dist/components/dialog.d.ts +22 -0
- package/dist/components/dialog.js +51 -0
- package/dist/components/dropdown-menu.d.ts +29 -0
- package/dist/components/dropdown-menu.js +52 -0
- package/dist/components/editable-doc-title.d.ts +17 -0
- package/dist/components/editable-doc-title.js +147 -0
- package/dist/components/empty-state.d.ts +12 -0
- package/dist/components/empty-state.js +6 -0
- package/dist/components/filter-condition-editor.d.ts +18 -0
- package/dist/components/filter-condition-editor.js +102 -0
- package/dist/components/form-dialog.d.ts +30 -0
- package/dist/components/form-dialog.js +52 -0
- package/dist/components/formula-editor.d.ts +18 -0
- package/dist/components/formula-editor.js +154 -0
- package/dist/components/hover-card.d.ts +52 -0
- package/dist/components/hover-card.js +51 -0
- package/dist/components/icon-button.d.ts +15 -0
- package/dist/components/icon-button.js +18 -0
- package/dist/components/inline-alert.d.ts +11 -0
- package/dist/components/inline-alert.js +17 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/input.js +7 -0
- package/dist/components/kanban-board.d.ts +27 -0
- package/dist/components/kanban-board.js +145 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/kbd.js +8 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +9 -0
- package/dist/components/markdown-editor/index.d.ts +4 -0
- package/dist/components/markdown-editor/index.js +2 -0
- package/dist/components/markdown-editor/markdown-editor.d.ts +16 -0
- package/dist/components/markdown-editor/markdown-editor.js +53 -0
- package/dist/components/markdown-editor/serialize.d.ts +12 -0
- package/dist/components/markdown-editor/serialize.js +122 -0
- package/dist/components/markdown-editor/vim.d.ts +8 -0
- package/dist/components/markdown-editor/vim.js +394 -0
- package/dist/components/metric-grid.d.ts +41 -0
- package/dist/components/metric-grid.js +39 -0
- package/dist/components/microphone-priority.d.ts +29 -0
- package/dist/components/microphone-priority.js +15 -0
- package/dist/components/middle-truncate.d.ts +6 -0
- package/dist/components/middle-truncate.js +15 -0
- package/dist/components/multi-combobox.d.ts +48 -0
- package/dist/components/multi-combobox.js +221 -0
- package/dist/components/naut-avatar-engine.d.ts +83 -0
- package/dist/components/naut-avatar-engine.js +803 -0
- package/dist/components/naut-avatar.d.ts +31 -0
- package/dist/components/naut-avatar.js +108 -0
- package/dist/components/navigable-list.d.ts +4 -0
- package/dist/components/navigable-list.js +20 -0
- package/dist/components/note-icon-picker.d.ts +20 -0
- package/dist/components/note-icon-picker.js +84 -0
- package/dist/components/note-icon.d.ts +690 -0
- package/dist/components/note-icon.js +353 -0
- package/dist/components/note-row.d.ts +33 -0
- package/dist/components/note-row.js +29 -0
- package/dist/components/overlapping-dots.d.ts +10 -0
- package/dist/components/overlapping-dots.js +13 -0
- package/dist/components/overview-card.d.ts +12 -0
- package/dist/components/overview-card.js +9 -0
- package/dist/components/panel-header.d.ts +8 -0
- package/dist/components/panel-header.js +6 -0
- package/dist/components/panel-section-states.d.ts +9 -0
- package/dist/components/panel-section-states.js +10 -0
- package/dist/components/person-avatar.d.ts +10 -0
- package/dist/components/person-avatar.js +23 -0
- package/dist/components/photo-avatar.d.ts +11 -0
- package/dist/components/photo-avatar.js +24 -0
- package/dist/components/picker-field.d.ts +23 -0
- package/dist/components/picker-field.js +24 -0
- package/dist/components/popover-stack.d.ts +26 -0
- package/dist/components/popover-stack.js +89 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.js +31 -0
- package/dist/components/portal-login-barrier.d.ts +12 -0
- package/dist/components/portal-login-barrier.js +41 -0
- package/dist/components/presence-dot.d.ts +8 -0
- package/dist/components/presence-dot.js +15 -0
- package/dist/components/presence-overlay.d.ts +27 -0
- package/dist/components/presence-overlay.js +34 -0
- package/dist/components/property-list.d.ts +64 -0
- package/dist/components/property-list.js +313 -0
- package/dist/components/property-panel.d.ts +54 -0
- package/dist/components/property-panel.js +87 -0
- package/dist/components/property-selector.d.ts +36 -0
- package/dist/components/property-selector.js +141 -0
- package/dist/components/provenance-chip.d.ts +12 -0
- package/dist/components/provenance-chip.js +17 -0
- package/dist/components/qr-code.d.ts +13 -0
- package/dist/components/qr-code.js +42 -0
- package/dist/components/qr-encode.d.ts +2 -0
- package/dist/components/qr-encode.js +469 -0
- package/dist/components/quantity-stepper.d.ts +25 -0
- package/dist/components/quantity-stepper.js +43 -0
- package/dist/components/radio-group.d.ts +5 -0
- package/dist/components/radio-group.js +13 -0
- package/dist/components/rename-dialog.d.ts +19 -0
- package/dist/components/rename-dialog.js +35 -0
- package/dist/components/row-surface.d.ts +1 -0
- package/dist/components/row-surface.js +5 -0
- package/dist/components/row-trailing.d.ts +30 -0
- package/dist/components/row-trailing.js +59 -0
- package/dist/components/run-status-badge.d.ts +16 -0
- package/dist/components/run-status-badge.js +43 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/scroll-area.js +12 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/select.js +39 -0
- package/dist/components/selectable-card.d.ts +33 -0
- package/dist/components/selectable-card.js +66 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +8 -0
- package/dist/components/settings-dialog-shell.d.ts +46 -0
- package/dist/components/settings-dialog-shell.js +48 -0
- package/dist/components/shimmer-text.d.ts +8 -0
- package/dist/components/shimmer-text.js +26 -0
- package/dist/components/side-panel-tokens.d.ts +27 -0
- package/dist/components/side-panel-tokens.js +26 -0
- package/dist/components/side-panel.d.ts +94 -0
- package/dist/components/side-panel.js +106 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +6 -0
- package/dist/components/sortable.d.ts +65 -0
- package/dist/components/sortable.js +110 -0
- package/dist/components/spec-strip.d.ts +18 -0
- package/dist/components/spec-strip.js +15 -0
- package/dist/components/speech-playback.d.ts +25 -0
- package/dist/components/speech-playback.js +35 -0
- package/dist/components/sql-editor.d.ts +13 -0
- package/dist/components/sql-editor.js +228 -0
- package/dist/components/stat-tile.d.ts +7 -0
- package/dist/components/stat-tile.js +6 -0
- package/dist/components/status-badge.d.ts +17 -0
- package/dist/components/status-badge.js +8 -0
- package/dist/components/status-tone.d.ts +9 -0
- package/dist/components/status-tone.js +10 -0
- package/dist/components/sticky-header-fade.d.ts +8 -0
- package/dist/components/sticky-header-fade.js +11 -0
- package/dist/components/swatch-button.d.ts +14 -0
- package/dist/components/swatch-button.js +25 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.js +9 -0
- package/dist/components/system-load/index.d.ts +6 -0
- package/dist/components/system-load/index.js +6 -0
- package/dist/components/system-load/load-block.d.ts +20 -0
- package/dist/components/system-load/load-block.js +23 -0
- package/dist/components/system-load/load-grid.d.ts +16 -0
- package/dist/components/system-load/load-grid.js +23 -0
- package/dist/components/system-load/load-meter.d.ts +25 -0
- package/dist/components/system-load/load-meter.js +29 -0
- package/dist/components/system-load/load-tone.d.ts +21 -0
- package/dist/components/system-load/load-tone.js +29 -0
- package/dist/components/system-load/meter-row.d.ts +31 -0
- package/dist/components/system-load/meter-row.js +29 -0
- package/dist/components/system-load/resource-meter.d.ts +19 -0
- package/dist/components/system-load/resource-meter.js +15 -0
- package/dist/components/tab-title-bar.d.ts +12 -0
- package/dist/components/tab-title-bar.js +9 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +29 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +97 -0
- package/dist/components/template-chip-input.d.ts +36 -0
- package/dist/components/template-chip-input.js +271 -0
- package/dist/components/template-input.d.ts +24 -0
- package/dist/components/template-input.js +57 -0
- package/dist/components/terminal-spinner.d.ts +11 -0
- package/dist/components/terminal-spinner.js +48 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +7 -0
- package/dist/components/time-column.d.ts +24 -0
- package/dist/components/time-column.js +60 -0
- package/dist/components/timestamped-transcript.d.ts +38 -0
- package/dist/components/timestamped-transcript.js +29 -0
- package/dist/components/timezone-picker.d.ts +22 -0
- package/dist/components/timezone-picker.js +60 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +29 -0
- package/dist/components/transcription-overlay.d.ts +47 -0
- package/dist/components/transcription-overlay.js +30 -0
- package/dist/components/usage-bar.d.ts +17 -0
- package/dist/components/usage-bar.js +26 -0
- package/dist/components/view-query-bar.d.ts +13 -0
- package/dist/components/view-query-bar.js +13 -0
- package/dist/components/view-query-controls.d.ts +159 -0
- package/dist/components/view-query-controls.js +109 -0
- package/dist/components/view-save-menu.d.ts +20 -0
- package/dist/components/view-save-menu.js +13 -0
- package/dist/components/view-sort-editor.d.ts +40 -0
- package/dist/components/view-sort-editor.js +47 -0
- package/dist/components/voice-line.d.ts +37 -0
- package/dist/components/voice-line.js +293 -0
- package/dist/components/weekly-schedule-editor.d.ts +15 -0
- package/dist/components/weekly-schedule-editor.js +28 -0
- package/dist/flow/canvas/canvas-frame.d.ts +160 -0
- package/dist/flow/canvas/canvas-frame.js +521 -0
- package/dist/flow/canvas/collaborator-layer.d.ts +12 -0
- package/dist/flow/canvas/collaborator-layer.js +43 -0
- package/dist/flow/canvas/connector-edge.d.ts +22 -0
- package/dist/flow/canvas/connector-edge.js +61 -0
- package/dist/flow/canvas/editor-context.d.ts +23 -0
- package/dist/flow/canvas/editor-context.js +6 -0
- package/dist/flow/canvas/graph-core.d.ts +60 -0
- package/dist/flow/canvas/graph-core.js +296 -0
- package/dist/flow/canvas/minimap-sticky-overlay.d.ts +4 -0
- package/dist/flow/canvas/minimap-sticky-overlay.js +45 -0
- package/dist/flow/canvas/node-card.d.ts +46 -0
- package/dist/flow/canvas/node-card.js +56 -0
- package/dist/flow/canvas/node-library.d.ts +40 -0
- package/dist/flow/canvas/node-library.js +54 -0
- package/dist/flow/canvas/sticky-notes.d.ts +25 -0
- package/dist/flow/canvas/sticky-notes.js +101 -0
- package/dist/flow/collaborative-graph-presence.d.ts +28 -0
- package/dist/flow/collaborative-graph-presence.js +55 -0
- package/dist/flow/collaborative-graph-sync.d.ts +40 -0
- package/dist/flow/collaborative-graph-sync.js +127 -0
- package/dist/flow/editor/adapter.d.ts +64 -0
- package/dist/flow/editor/adapter.js +1 -0
- package/dist/flow/editor/command-registry.d.ts +10 -0
- package/dist/flow/editor/command-registry.js +35 -0
- package/dist/flow/editor/dag-canvas.d.ts +18 -0
- package/dist/flow/editor/dag-canvas.js +33 -0
- package/dist/flow/editor/flow-editor.d.ts +54 -0
- package/dist/flow/editor/flow-editor.js +199 -0
- package/dist/flow/editor/issues-popover.d.ts +11 -0
- package/dist/flow/editor/issues-popover.js +70 -0
- package/dist/flow/editor/library-rail.d.ts +19 -0
- package/dist/flow/editor/library-rail.js +25 -0
- package/dist/flow/editor/make-controller.d.ts +18 -0
- package/dist/flow/editor/make-controller.js +44 -0
- package/dist/flow/editor/node-chip.d.ts +2 -0
- package/dist/flow/editor/node-chip.js +16 -0
- package/dist/flow/editor/save-publish-bar.d.ts +27 -0
- package/dist/flow/editor/save-publish-bar.js +14 -0
- package/dist/flow/editor/settings-dialog.d.ts +11 -0
- package/dist/flow/editor/settings-dialog.js +11 -0
- package/dist/flow/editor/settings-shell.d.ts +21 -0
- package/dist/flow/editor/settings-shell.js +20 -0
- package/dist/flow/editor/side-rail.d.ts +22 -0
- package/dist/flow/editor/side-rail.js +15 -0
- package/dist/flow/editor/use-dag-editor.d.ts +94 -0
- package/dist/flow/editor/use-dag-editor.js +502 -0
- package/dist/flow/index.d.ts +25 -0
- package/dist/flow/index.js +25 -0
- package/dist/flow/presence-motion.d.ts +10 -0
- package/dist/flow/presence-motion.js +88 -0
- package/dist/flow/styles.css +1 -0
- package/dist/flow/use-collaborative-graph.d.ts +61 -0
- package/dist/flow/use-collaborative-graph.js +396 -0
- package/dist/flow/use-debounced-value.d.ts +1 -0
- package/dist/flow/use-debounced-value.js +10 -0
- package/dist/hooks/use-detail-nav.d.ts +11 -0
- package/dist/hooks/use-detail-nav.js +49 -0
- package/dist/hooks/use-flush-on-hide.d.ts +1 -0
- package/dist/hooks/use-flush-on-hide.js +21 -0
- package/dist/hooks/use-media-query.d.ts +1 -0
- package/dist/hooks/use-media-query.js +20 -0
- package/dist/hooks/use-virtualizer.d.ts +1 -0
- package/dist/hooks/use-virtualizer.js +1 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +139 -0
- package/dist/lib/brand-style.d.ts +6 -0
- package/dist/lib/brand-style.js +16 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/composited-glint.d.ts +7 -0
- package/dist/lib/composited-glint.js +98 -0
- package/dist/lib/date-time-format.d.ts +2 -0
- package/dist/lib/date-time-format.js +21 -0
- package/dist/lib/disclosure-state.d.ts +11 -0
- package/dist/lib/disclosure-state.js +22 -0
- package/dist/lib/label-swatches.d.ts +10 -0
- package/dist/lib/label-swatches.js +24 -0
- package/dist/lib/local-ui-state.d.ts +10 -0
- package/dist/lib/local-ui-state.js +95 -0
- package/dist/lib/parse-loose-datetime.d.ts +1 -0
- package/dist/lib/parse-loose-datetime.js +180 -0
- package/dist/lib/parse-loose-time.d.ts +6 -0
- package/dist/lib/parse-loose-time.js +53 -0
- package/dist/lib/parse-loose.d.ts +1 -0
- package/dist/lib/parse-loose.js +170 -0
- package/dist/lib/react-19-jsx.d.ts +8 -0
- package/dist/lib/react-19-jsx.js +1 -0
- package/dist/lib/view-chrome.d.ts +5 -0
- package/dist/lib/view-chrome.js +5 -0
- package/dist/lib/view-query/config.d.ts +26 -0
- package/dist/lib/view-query/config.js +162 -0
- package/dist/lib/view-query/evaluate.d.ts +11 -0
- package/dist/lib/view-query/evaluate.js +196 -0
- package/dist/lib/view-query/group-order.d.ts +25 -0
- package/dist/lib/view-query/group-order.js +49 -0
- package/dist/lib/view-query/index.d.ts +6 -0
- package/dist/lib/view-query/index.js +6 -0
- package/dist/lib/view-query/model.d.ts +34 -0
- package/dist/lib/view-query/model.js +88 -0
- package/dist/lib/view-query/sort.d.ts +7 -0
- package/dist/lib/view-query/sort.js +30 -0
- package/dist/lib/view-query/types.d.ts +70 -0
- package/dist/lib/view-query/types.js +12 -0
- package/dist/lib/weekly-schedule.d.ts +8 -0
- package/dist/lib/weekly-schedule.js +10 -0
- package/dist/mcp-app/index.d.ts +4 -0
- package/dist/mcp-app/index.js +3 -0
- package/dist/mcp-app/shadcn.css +629 -0
- package/dist/mcp-app/styles.css +72 -0
- package/dist/mcp-app/theme.d.ts +2 -0
- package/dist/mcp-app/theme.js +62 -0
- package/dist/mcp-app/use-atmos-mcp-app.d.ts +109 -0
- package/dist/mcp-app/use-atmos-mcp-app.js +30 -0
- package/dist/mcp-app/vite.d.ts +7 -0
- package/dist/mcp-app/vite.js +30 -0
- package/dist/tokens/index.d.ts +7 -0
- package/dist/tokens/index.js +7 -0
- package/dist/tokens/semantic.css +110 -0
- package/dist/tokens/tokens.css +195 -0
- package/package.json +98 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { serializeMarkdown } from './serialize.js';
|
|
2
|
+
export interface MarkdownEditorProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (markdown: string) => void;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
autoFocus?: boolean;
|
|
9
|
+
testId?: string;
|
|
10
|
+
vimMode?: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare function markdownToHtml(md: string): string;
|
|
15
|
+
export declare function MarkdownEditor({ value, onChange, placeholder, className, readOnly, autoFocus, testId, vimMode, }: MarkdownEditorProps): import("react").JSX.Element;
|
|
16
|
+
export { serializeMarkdown, markdownToHtml };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { EditorContent, useEditor } from '@tiptap/react';
|
|
4
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
5
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
6
|
+
import { marked } from 'marked';
|
|
7
|
+
import { useEffect, useRef } from 'react';
|
|
8
|
+
import { VimExtension } from './vim.js';
|
|
9
|
+
import { cn } from '../../lib/cn.js';
|
|
10
|
+
import { serializeMarkdown } from './serialize.js';
|
|
11
|
+
const STARTER_KIT_OPTIONS = {
|
|
12
|
+
heading: { levels: [1, 2, 3] },
|
|
13
|
+
};
|
|
14
|
+
function markdownToHtml(md) {
|
|
15
|
+
if (!md)
|
|
16
|
+
return '';
|
|
17
|
+
return marked.parse(md, { gfm: true, breaks: false, async: false });
|
|
18
|
+
}
|
|
19
|
+
export function MarkdownEditor({ value, onChange, placeholder, className, readOnly, autoFocus, testId, vimMode = { enabled: false }, }) {
|
|
20
|
+
const lastEmittedRef = useRef('');
|
|
21
|
+
const editor = useEditor({
|
|
22
|
+
immediatelyRender: false,
|
|
23
|
+
extensions: [
|
|
24
|
+
StarterKit.configure(STARTER_KIT_OPTIONS),
|
|
25
|
+
VimExtension.configure({ enabled: vimMode.enabled }),
|
|
26
|
+
Placeholder.configure({ placeholder: placeholder ?? '' }),
|
|
27
|
+
],
|
|
28
|
+
content: markdownToHtml(value),
|
|
29
|
+
editable: !readOnly,
|
|
30
|
+
autofocus: autoFocus ?? false,
|
|
31
|
+
onUpdate({ editor }) {
|
|
32
|
+
const json = editor.getJSON();
|
|
33
|
+
const md = serializeMarkdown(json);
|
|
34
|
+
lastEmittedRef.current = md;
|
|
35
|
+
onChange(md);
|
|
36
|
+
},
|
|
37
|
+
}, [vimMode.enabled]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!editor)
|
|
40
|
+
return;
|
|
41
|
+
if (value === lastEmittedRef.current)
|
|
42
|
+
return;
|
|
43
|
+
editor.commands.setContent(markdownToHtml(value), false);
|
|
44
|
+
lastEmittedRef.current = value;
|
|
45
|
+
}, [editor, value]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!editor)
|
|
48
|
+
return;
|
|
49
|
+
editor.setEditable(!readOnly);
|
|
50
|
+
}, [editor, readOnly]);
|
|
51
|
+
return (_jsx("div", { className: "relative", children: _jsx(EditorContent, { editor: editor, "data-testid": testId, className: cn('prose prose-sm dark:prose-invert max-w-none', '[&_.ProseMirror]:min-h-[72px] [&_.ProseMirror]:px-2 [&_.ProseMirror]:py-1.5 [&_.ProseMirror]:outline-none', '[&_.ProseMirror_p.is-editor-empty:first-child]:before:content-[attr(data-placeholder)]', '[&_.ProseMirror_p.is-editor-empty:first-child]:before:text-muted-foreground/60', '[&_.ProseMirror_p.is-editor-empty:first-child]:before:float-left', '[&_.ProseMirror_p.is-editor-empty:first-child]:before:pointer-events-none', className) }) }));
|
|
52
|
+
}
|
|
53
|
+
export { serializeMarkdown, markdownToHtml };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TiptapNode {
|
|
2
|
+
type: string;
|
|
3
|
+
attrs?: Record<string, unknown>;
|
|
4
|
+
content?: TiptapNode[];
|
|
5
|
+
marks?: TiptapMark[];
|
|
6
|
+
text?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TiptapMark {
|
|
9
|
+
type: string;
|
|
10
|
+
attrs?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare function serializeMarkdown(doc: TiptapNode | null | undefined): string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export function serializeMarkdown(doc) {
|
|
2
|
+
if (!doc || !doc.content)
|
|
3
|
+
return '';
|
|
4
|
+
return doc.content.map((node) => block(node)).join('\n\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
5
|
+
}
|
|
6
|
+
function block(node) {
|
|
7
|
+
switch (node.type) {
|
|
8
|
+
case 'paragraph':
|
|
9
|
+
return inlineRun(node.content ?? []);
|
|
10
|
+
case 'heading': {
|
|
11
|
+
const level = clampHeadingLevel(node.attrs?.level);
|
|
12
|
+
return '#'.repeat(level) + ' ' + inlineRun(node.content ?? []);
|
|
13
|
+
}
|
|
14
|
+
case 'blockquote':
|
|
15
|
+
return (node.content ?? [])
|
|
16
|
+
.map((c) => block(c))
|
|
17
|
+
.join('\n\n')
|
|
18
|
+
.split('\n')
|
|
19
|
+
.map((line) => (line ? '> ' + line : '>'))
|
|
20
|
+
.join('\n');
|
|
21
|
+
case 'bulletList':
|
|
22
|
+
return (node.content ?? [])
|
|
23
|
+
.map((li) => listItem(li, '- '))
|
|
24
|
+
.join('\n');
|
|
25
|
+
case 'orderedList':
|
|
26
|
+
return (node.content ?? [])
|
|
27
|
+
.map((li, i) => listItem(li, `${i + 1}. `))
|
|
28
|
+
.join('\n');
|
|
29
|
+
case 'codeBlock': {
|
|
30
|
+
const lang = node.attrs?.language ?? '';
|
|
31
|
+
const body = (node.content ?? [])
|
|
32
|
+
.map((c) => c.text ?? '')
|
|
33
|
+
.join('');
|
|
34
|
+
return '```' + lang + '\n' + body + '\n```';
|
|
35
|
+
}
|
|
36
|
+
case 'horizontalRule':
|
|
37
|
+
return '---';
|
|
38
|
+
case 'hardBreak':
|
|
39
|
+
return ' \n';
|
|
40
|
+
default:
|
|
41
|
+
return inlineRun(node.content ?? []);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function listItem(li, marker) {
|
|
45
|
+
const indent = ' '.repeat(marker.length);
|
|
46
|
+
const inner = (li.content ?? [])
|
|
47
|
+
.map((c) => block(c))
|
|
48
|
+
.join('\n\n');
|
|
49
|
+
const lines = inner.split('\n');
|
|
50
|
+
return lines
|
|
51
|
+
.map((line, i) => (i === 0 ? marker + line : indent + line))
|
|
52
|
+
.join('\n');
|
|
53
|
+
}
|
|
54
|
+
function inlineRun(nodes) {
|
|
55
|
+
return nodes.map((n) => inline(n)).join('');
|
|
56
|
+
}
|
|
57
|
+
function inline(node) {
|
|
58
|
+
if (node.type === 'hardBreak')
|
|
59
|
+
return ' \n';
|
|
60
|
+
if (node.type !== 'text') {
|
|
61
|
+
return inlineRun(node.content ?? []);
|
|
62
|
+
}
|
|
63
|
+
const raw = escapeMarkdown(node.text ?? '');
|
|
64
|
+
return applyMarks(raw, node.marks ?? []);
|
|
65
|
+
}
|
|
66
|
+
function applyMarks(text, marks) {
|
|
67
|
+
let out = text;
|
|
68
|
+
const codeMark = marks.find((m) => m.type === 'code');
|
|
69
|
+
if (codeMark) {
|
|
70
|
+
const ticks = longestRun(out, '`') + 1;
|
|
71
|
+
return '`'.repeat(ticks) + out + '`'.repeat(ticks);
|
|
72
|
+
}
|
|
73
|
+
for (const m of marks) {
|
|
74
|
+
switch (m.type) {
|
|
75
|
+
case 'bold':
|
|
76
|
+
out = `**${out}**`;
|
|
77
|
+
break;
|
|
78
|
+
case 'italic':
|
|
79
|
+
out = `*${out}*`;
|
|
80
|
+
break;
|
|
81
|
+
case 'strike':
|
|
82
|
+
out = `~~${out}~~`;
|
|
83
|
+
break;
|
|
84
|
+
case 'link': {
|
|
85
|
+
const rawHref = m.attrs?.href;
|
|
86
|
+
const href = typeof rawHref === 'string' ? rawHref : '';
|
|
87
|
+
if (href)
|
|
88
|
+
out = `[${out}](${href})`;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
function escapeMarkdown(s) {
|
|
96
|
+
return s.replace(/([\\`*_[\]<>])/g, '\\$1');
|
|
97
|
+
}
|
|
98
|
+
function longestRun(s, ch) {
|
|
99
|
+
let max = 0;
|
|
100
|
+
let cur = 0;
|
|
101
|
+
for (const c of s) {
|
|
102
|
+
if (c === ch) {
|
|
103
|
+
cur++;
|
|
104
|
+
if (cur > max)
|
|
105
|
+
max = cur;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
cur = 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return max;
|
|
112
|
+
}
|
|
113
|
+
function clampHeadingLevel(v) {
|
|
114
|
+
const n = typeof v === 'number'
|
|
115
|
+
? v
|
|
116
|
+
: typeof v === 'string'
|
|
117
|
+
? Number.parseInt(v, 10)
|
|
118
|
+
: 1;
|
|
119
|
+
if (Number.isNaN(n))
|
|
120
|
+
return 1;
|
|
121
|
+
return Math.max(1, Math.min(6, n));
|
|
122
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
export type VimMode = 'insert' | 'normal' | 'visual';
|
|
3
|
+
export interface VimExtensionOptions {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
initialMode: VimMode;
|
|
6
|
+
onModeChange?: (mode: VimMode) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const VimExtension: Extension<VimExtensionOptions, any>;
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state';
|
|
3
|
+
export const VimExtension = Extension.create({
|
|
4
|
+
name: 'atmosVim',
|
|
5
|
+
addOptions() {
|
|
6
|
+
return {
|
|
7
|
+
enabled: true,
|
|
8
|
+
initialMode: 'insert',
|
|
9
|
+
onModeChange: undefined,
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
addProseMirrorPlugins() {
|
|
13
|
+
if (!this.options.enabled)
|
|
14
|
+
return [];
|
|
15
|
+
let mode = this.options.initialMode;
|
|
16
|
+
const onModeChange = this.options.onModeChange;
|
|
17
|
+
let visualAnchor = null;
|
|
18
|
+
let pending = null;
|
|
19
|
+
let yank = null;
|
|
20
|
+
const setMode = (next, view) => {
|
|
21
|
+
mode = next;
|
|
22
|
+
pending = null;
|
|
23
|
+
if (next !== 'visual')
|
|
24
|
+
visualAnchor = null;
|
|
25
|
+
view.dom.dataset.vimMode = next;
|
|
26
|
+
onModeChange?.(next);
|
|
27
|
+
};
|
|
28
|
+
return [
|
|
29
|
+
new Plugin({
|
|
30
|
+
key: new PluginKey('atmosVim'),
|
|
31
|
+
view(view) {
|
|
32
|
+
view.dom.dataset.vimMode = mode;
|
|
33
|
+
onModeChange?.(mode);
|
|
34
|
+
return {
|
|
35
|
+
destroy() {
|
|
36
|
+
delete view.dom.dataset.vimMode;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
props: {
|
|
41
|
+
handleKeyDown(view, event) {
|
|
42
|
+
if (event.metaKey || event.ctrlKey || event.altKey)
|
|
43
|
+
return false;
|
|
44
|
+
if (mode === 'insert') {
|
|
45
|
+
if (event.key !== 'Escape')
|
|
46
|
+
return false;
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
setMode('normal', view);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (pending === 'g') {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
pending = null;
|
|
54
|
+
if (event.key === 'g')
|
|
55
|
+
moveDocBoundary(view, 'start');
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (pending === 'd') {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
pending = null;
|
|
61
|
+
if (event.key === 'd') {
|
|
62
|
+
yank = { kind: 'block', text: currentBlockText(view) };
|
|
63
|
+
deleteCurrentBlock(view);
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (pending === 'y') {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
pending = null;
|
|
70
|
+
if (event.key === 'y')
|
|
71
|
+
yank = { kind: 'block', text: currentBlockText(view) };
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (event.key === 'Escape') {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
if (mode === 'visual') {
|
|
77
|
+
setMode('normal', view);
|
|
78
|
+
collapseSelection(view);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
view.dom.blur();
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (mode === 'normal' && (event.key === 'i' || event.key === 'I')) {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
setMode('insert', view);
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (mode === 'normal' && event.key === 'a') {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
moveChar(view, 1);
|
|
93
|
+
setMode('insert', view);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (mode === 'normal' && (event.key === 'o' || event.key === 'O')) {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
insertParagraph(view, event.key === 'O' ? 'before' : 'after');
|
|
99
|
+
setMode('insert', view);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (mode === 'normal' && event.key === 'v') {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
visualAnchor = view.state.selection.from;
|
|
105
|
+
setMode('visual', view);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
if (mode === 'normal' && event.key === 'g') {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
pending = 'g';
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (mode === 'normal' && event.key === 'G') {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
moveDocBoundary(view, 'end');
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (mode === 'normal' && event.key === 'd') {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
pending = 'd';
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
if (mode === 'normal' && event.key === 'y') {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
pending = 'y';
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
if (mode === 'normal' && event.key === 'x') {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
deleteChar(view);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
if (mode === 'normal' && event.key === 'p') {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
pasteYank(view, yank);
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
if (mode === 'visual' && event.key === 'y') {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
yank = { kind: 'text', text: selectedText(view) };
|
|
141
|
+
setMode('normal', view);
|
|
142
|
+
collapseSelection(view);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
if (mode === 'visual' && event.key === 'd') {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
yank = { kind: 'text', text: selectedText(view) };
|
|
148
|
+
deleteSelection(view);
|
|
149
|
+
setMode('normal', view);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (event.key === '0') {
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
if (mode === 'visual')
|
|
155
|
+
extendToLineBoundary(view, visualAnchor, 'start');
|
|
156
|
+
else
|
|
157
|
+
moveLineBoundary(view, 'start');
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (event.key === '$') {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
if (mode === 'visual')
|
|
163
|
+
extendToLineBoundary(view, visualAnchor, 'end');
|
|
164
|
+
else
|
|
165
|
+
moveLineBoundary(view, 'end');
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (event.key === 'w') {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
if (mode === 'visual')
|
|
171
|
+
extendToWord(view, visualAnchor, 'next');
|
|
172
|
+
else
|
|
173
|
+
moveWord(view, 'next');
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
if (event.key === 'b') {
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
if (mode === 'visual')
|
|
179
|
+
extendToWord(view, visualAnchor, 'previous');
|
|
180
|
+
else
|
|
181
|
+
moveWord(view, 'previous');
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
if (event.key === 'e') {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
if (mode === 'visual')
|
|
187
|
+
extendToWord(view, visualAnchor, 'end');
|
|
188
|
+
else
|
|
189
|
+
moveWord(view, 'end');
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
if (event.key === 'h' || event.key === 'ArrowLeft') {
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
if (mode === 'visual')
|
|
195
|
+
extendSelection(view, visualAnchor, -1);
|
|
196
|
+
else
|
|
197
|
+
moveChar(view, -1);
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (event.key === 'l' || event.key === 'ArrowRight') {
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
if (mode === 'visual')
|
|
203
|
+
extendSelection(view, visualAnchor, 1);
|
|
204
|
+
else
|
|
205
|
+
moveChar(view, 1);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
if (event.key === 'j' || event.key === 'ArrowDown') {
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
if (mode === 'visual')
|
|
211
|
+
extendBlock(view, visualAnchor, 1);
|
|
212
|
+
else
|
|
213
|
+
moveBlock(view, 1);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
if (event.key === 'k' || event.key === 'ArrowUp') {
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
if (mode === 'visual')
|
|
219
|
+
extendBlock(view, visualAnchor, -1);
|
|
220
|
+
else
|
|
221
|
+
moveBlock(view, -1);
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
if (event.key.length === 1) {
|
|
225
|
+
event.preventDefault();
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
}),
|
|
232
|
+
];
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
function textPos(view, pos) {
|
|
236
|
+
return textPosInDoc(view.state.doc, pos);
|
|
237
|
+
}
|
|
238
|
+
function textPosInDoc(doc, pos) {
|
|
239
|
+
return Math.max(1, Math.min(pos, doc.content.size));
|
|
240
|
+
}
|
|
241
|
+
function moveChar(view, delta) {
|
|
242
|
+
const next = textPos(view, view.state.selection.to + delta);
|
|
243
|
+
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, next)).scrollIntoView());
|
|
244
|
+
}
|
|
245
|
+
function extendSelection(view, anchor, delta) {
|
|
246
|
+
const from = anchor ?? view.state.selection.from;
|
|
247
|
+
const to = textPos(view, view.state.selection.to + delta);
|
|
248
|
+
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, from, to)).scrollIntoView());
|
|
249
|
+
}
|
|
250
|
+
function moveBlock(view, delta) {
|
|
251
|
+
const { state } = view;
|
|
252
|
+
const current = state.selection.$from;
|
|
253
|
+
const index = current.index(0) + delta;
|
|
254
|
+
if (index < 0 || index >= state.doc.childCount)
|
|
255
|
+
return;
|
|
256
|
+
let pos = 1;
|
|
257
|
+
for (let i = 0; i < index; i += 1)
|
|
258
|
+
pos += state.doc.child(i).nodeSize;
|
|
259
|
+
view.dispatch(state.tr.setSelection(TextSelection.create(state.doc, textPos(view, pos))).scrollIntoView());
|
|
260
|
+
}
|
|
261
|
+
function extendBlock(view, anchor, delta) {
|
|
262
|
+
moveBlock(view, delta);
|
|
263
|
+
const from = anchor ?? view.state.selection.from;
|
|
264
|
+
const to = view.state.selection.to;
|
|
265
|
+
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, from, to)).scrollIntoView());
|
|
266
|
+
}
|
|
267
|
+
function insertParagraph(view, side) {
|
|
268
|
+
const { state } = view;
|
|
269
|
+
const $from = state.selection.$from;
|
|
270
|
+
const at = side === 'before' ? $from.before(1) : $from.after(1);
|
|
271
|
+
const paragraph = state.schema.nodes.paragraph?.create();
|
|
272
|
+
if (!paragraph)
|
|
273
|
+
return;
|
|
274
|
+
const tr = state.tr.insert(at, paragraph);
|
|
275
|
+
const pos = side === 'before' ? at + 1 : at + paragraph.nodeSize - 1;
|
|
276
|
+
view.dispatch(tr.setSelection(TextSelection.create(tr.doc, textPosInDoc(tr.doc, pos))).scrollIntoView());
|
|
277
|
+
}
|
|
278
|
+
function collapseSelection(view) {
|
|
279
|
+
const pos = view.state.selection.to;
|
|
280
|
+
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, pos)));
|
|
281
|
+
}
|
|
282
|
+
function moveDocBoundary(view, side) {
|
|
283
|
+
const pos = side === 'start' ? 1 : view.state.doc.content.size - 1;
|
|
284
|
+
view.dispatch(view.state.tr
|
|
285
|
+
.setSelection(TextSelection.create(view.state.doc, textPos(view, pos)))
|
|
286
|
+
.scrollIntoView());
|
|
287
|
+
}
|
|
288
|
+
function lineBounds(view) {
|
|
289
|
+
const $from = view.state.selection.$from;
|
|
290
|
+
return {
|
|
291
|
+
start: $from.start(),
|
|
292
|
+
end: $from.end(),
|
|
293
|
+
offset: $from.parentOffset,
|
|
294
|
+
text: $from.parent.textContent,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function moveLineBoundary(view, side) {
|
|
298
|
+
const bounds = lineBounds(view);
|
|
299
|
+
const pos = side === 'start' ? bounds.start : bounds.end;
|
|
300
|
+
view.dispatch(view.state.tr
|
|
301
|
+
.setSelection(TextSelection.create(view.state.doc, textPos(view, pos)))
|
|
302
|
+
.scrollIntoView());
|
|
303
|
+
}
|
|
304
|
+
function extendToLineBoundary(view, anchor, side) {
|
|
305
|
+
const bounds = lineBounds(view);
|
|
306
|
+
const to = side === 'start' ? bounds.start : bounds.end;
|
|
307
|
+
view.dispatch(view.state.tr
|
|
308
|
+
.setSelection(TextSelection.create(view.state.doc, anchor ?? view.state.selection.from, textPos(view, to)))
|
|
309
|
+
.scrollIntoView());
|
|
310
|
+
}
|
|
311
|
+
function moveWord(view, direction) {
|
|
312
|
+
const pos = wordPos(view, direction);
|
|
313
|
+
view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, pos)).scrollIntoView());
|
|
314
|
+
}
|
|
315
|
+
function extendToWord(view, anchor, direction) {
|
|
316
|
+
const to = wordPos(view, direction);
|
|
317
|
+
view.dispatch(view.state.tr
|
|
318
|
+
.setSelection(TextSelection.create(view.state.doc, anchor ?? view.state.selection.from, to))
|
|
319
|
+
.scrollIntoView());
|
|
320
|
+
}
|
|
321
|
+
function wordPos(view, direction) {
|
|
322
|
+
const bounds = lineBounds(view);
|
|
323
|
+
const nextOffset = wordOffset(bounds.text, bounds.offset, direction);
|
|
324
|
+
return textPos(view, bounds.start + nextOffset);
|
|
325
|
+
}
|
|
326
|
+
function wordOffset(text, offset, direction) {
|
|
327
|
+
if (direction === 'next') {
|
|
328
|
+
const rest = text.slice(offset);
|
|
329
|
+
const match = /\W+\w|\w+\W+\w/.exec(rest);
|
|
330
|
+
if (!match)
|
|
331
|
+
return text.length;
|
|
332
|
+
return offset + match.index + match[0].length - 1;
|
|
333
|
+
}
|
|
334
|
+
if (direction === 'end') {
|
|
335
|
+
const rest = text.slice(offset + 1);
|
|
336
|
+
const match = /\w\b/.exec(rest);
|
|
337
|
+
if (!match)
|
|
338
|
+
return text.length;
|
|
339
|
+
return offset + 1 + match.index;
|
|
340
|
+
}
|
|
341
|
+
const before = text.slice(0, Math.max(0, offset - 1));
|
|
342
|
+
const matches = [...before.matchAll(/\b\w/g)];
|
|
343
|
+
return matches.at(-1)?.index ?? 0;
|
|
344
|
+
}
|
|
345
|
+
function currentBlockText(view) {
|
|
346
|
+
return view.state.selection.$from.parent.textContent;
|
|
347
|
+
}
|
|
348
|
+
function deleteCurrentBlock(view) {
|
|
349
|
+
const { state } = view;
|
|
350
|
+
const $from = state.selection.$from;
|
|
351
|
+
const from = $from.before();
|
|
352
|
+
const to = $from.after();
|
|
353
|
+
const paragraph = state.schema.nodes.paragraph?.create();
|
|
354
|
+
const tr = state.tr.delete(from, to);
|
|
355
|
+
if (tr.doc.childCount === 0 && paragraph)
|
|
356
|
+
tr.insert(0, paragraph);
|
|
357
|
+
const pos = Math.min(from + 1, tr.doc.content.size - 1);
|
|
358
|
+
view.dispatch(tr.setSelection(TextSelection.create(tr.doc, textPosInDoc(tr.doc, pos))).scrollIntoView());
|
|
359
|
+
}
|
|
360
|
+
function deleteChar(view) {
|
|
361
|
+
const { state } = view;
|
|
362
|
+
const from = state.selection.from;
|
|
363
|
+
const to = Math.min(from + 1, state.doc.content.size);
|
|
364
|
+
if (from >= to)
|
|
365
|
+
return;
|
|
366
|
+
view.dispatch(state.tr.delete(from, to).scrollIntoView());
|
|
367
|
+
}
|
|
368
|
+
function selectedText(view) {
|
|
369
|
+
const { from, to } = view.state.selection;
|
|
370
|
+
return view.state.doc.textBetween(Math.min(from, to), Math.max(from, to), '\n');
|
|
371
|
+
}
|
|
372
|
+
function deleteSelection(view) {
|
|
373
|
+
const { state } = view;
|
|
374
|
+
const { from, to } = state.selection;
|
|
375
|
+
if (from === to)
|
|
376
|
+
return;
|
|
377
|
+
view.dispatch(state.tr.delete(Math.min(from, to), Math.max(from, to)).scrollIntoView());
|
|
378
|
+
}
|
|
379
|
+
function pasteYank(view, yank) {
|
|
380
|
+
if (!yank || !yank.text)
|
|
381
|
+
return;
|
|
382
|
+
const { state } = view;
|
|
383
|
+
if (yank.kind === 'text') {
|
|
384
|
+
const at = state.selection.to;
|
|
385
|
+
view.dispatch(state.tr.insertText(yank.text, at).scrollIntoView());
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const paragraph = state.schema.nodes.paragraph?.create(null, state.schema.text(yank.text));
|
|
389
|
+
if (!paragraph)
|
|
390
|
+
return;
|
|
391
|
+
const at = state.selection.$from.after();
|
|
392
|
+
const tr = state.tr.insert(at, paragraph);
|
|
393
|
+
view.dispatch(tr.setSelection(TextSelection.create(tr.doc, textPosInDoc(tr.doc, at + 1))).scrollIntoView());
|
|
394
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type MetricTone = 'neutral' | 'success' | 'warning' | 'danger';
|
|
3
|
+
export interface MetricSectionHeadingProps extends Omit<React.ComponentProps<'div'>, 'title'> {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
hint?: React.ReactNode;
|
|
6
|
+
action?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function MetricSectionHeading({ title, hint, action, className, ...props }: MetricSectionHeadingProps): React.JSX.Element;
|
|
9
|
+
export type MetricGridProps = React.ComponentProps<'div'>;
|
|
10
|
+
export declare function MetricGrid({ className, ...props }: MetricGridProps): React.JSX.Element;
|
|
11
|
+
export interface MetricPanelProps extends Omit<React.ComponentProps<'div'>, 'title'> {
|
|
12
|
+
title?: React.ReactNode;
|
|
13
|
+
action?: React.ReactNode;
|
|
14
|
+
padding?: 'none' | 'sm' | 'md';
|
|
15
|
+
}
|
|
16
|
+
export declare function MetricPanel({ title, action, padding, className, children, ...props }: MetricPanelProps): React.JSX.Element;
|
|
17
|
+
export interface MetricTileProps extends Omit<React.ComponentProps<'div'>, 'title'> {
|
|
18
|
+
/** Omit when the value carries its own meaning — a unit suffix can be the whole caption. */
|
|
19
|
+
label?: React.ReactNode;
|
|
20
|
+
value: React.ReactNode;
|
|
21
|
+
suffix?: React.ReactNode;
|
|
22
|
+
hint?: React.ReactNode;
|
|
23
|
+
tone?: MetricTone;
|
|
24
|
+
}
|
|
25
|
+
export declare function MetricTile({ label, value, suffix, hint, tone, className, ...props }: MetricTileProps): React.JSX.Element;
|
|
26
|
+
export interface MetricBreakdownItem {
|
|
27
|
+
key: string;
|
|
28
|
+
label: React.ReactNode;
|
|
29
|
+
value: React.ReactNode;
|
|
30
|
+
fraction?: number;
|
|
31
|
+
tone?: MetricTone;
|
|
32
|
+
title?: string;
|
|
33
|
+
onSelect?: () => void;
|
|
34
|
+
}
|
|
35
|
+
export interface MetricBreakdownProps extends Omit<React.ComponentProps<'div'>, 'title'> {
|
|
36
|
+
title?: React.ReactNode;
|
|
37
|
+
items: MetricBreakdownItem[];
|
|
38
|
+
emptyLabel?: React.ReactNode;
|
|
39
|
+
showBars?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare function MetricBreakdown({ title, items, emptyLabel, showBars, className, ...props }: MetricBreakdownProps): React.JSX.Element;
|