@diegopluna/narvi 0.1.0 → 0.3.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 +102 -41
- package/dist/base.css +2 -2
- package/dist/color.d.ts +2 -2
- package/dist/color.js +1 -1
- package/dist/components/activity/ActivityContent.svelte +5 -17
- package/dist/components/activity/ActivityContent.svelte.d.ts +2 -2
- package/dist/components/activity/ActivityRoot.svelte +5 -5
- package/dist/components/activity/ActivityRoot.svelte.d.ts +5 -5
- package/dist/components/activity/ActivityStep.svelte +21 -21
- package/dist/components/activity/ActivityStep.svelte.d.ts +9 -9
- package/dist/components/activity/ActivityThought.svelte +7 -7
- package/dist/components/activity/ActivityThought.svelte.d.ts +3 -3
- package/dist/components/activity/ActivityTrigger.svelte +8 -8
- package/dist/components/activity/ActivityTrigger.svelte.d.ts +5 -5
- package/dist/components/announcer/Announcer.svelte +5 -18
- package/dist/components/announcer/Announcer.svelte.d.ts +3 -3
- package/dist/components/app-shell/AppShellBar.svelte +89 -0
- package/dist/components/app-shell/AppShellBar.svelte.d.ts +20 -0
- package/dist/components/app-shell/AppShellHeader.svelte +20 -19
- package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -5
- package/dist/components/app-shell/AppShellMain.svelte +6 -22
- package/dist/components/app-shell/AppShellMain.svelte.d.ts +2 -2
- package/dist/components/app-shell/AppShellPanel.svelte +27 -25
- package/dist/components/app-shell/AppShellPanel.svelte.d.ts +6 -6
- package/dist/components/app-shell/AppShellPanes.svelte +58 -0
- package/dist/components/app-shell/AppShellPanes.svelte.d.ts +11 -0
- package/dist/components/app-shell/AppShellRail.svelte +85 -0
- package/dist/components/app-shell/AppShellRail.svelte.d.ts +11 -0
- package/dist/components/app-shell/AppShellRoot.svelte +58 -32
- package/dist/components/app-shell/AppShellRoot.svelte.d.ts +16 -14
- package/dist/components/app-shell/AppShellSheet.svelte +95 -0
- package/dist/components/app-shell/AppShellSheet.svelte.d.ts +17 -0
- package/dist/components/app-shell/AppShellSidebar.svelte +40 -64
- package/dist/components/app-shell/AppShellSidebar.svelte.d.ts +4 -8
- package/dist/components/app-shell/AppShellToggle.svelte +66 -26
- package/dist/components/app-shell/AppShellToggle.svelte.d.ts +5 -3
- package/dist/components/app-shell/context.d.ts +6 -0
- package/dist/components/app-shell/index.d.ts +9 -1
- package/dist/components/app-shell/index.js +5 -1
- package/dist/components/approval/Approval.svelte +101 -29
- package/dist/components/approval/Approval.svelte.d.ts +17 -10
- package/dist/components/avatar/AvatarFallback.svelte +4 -4
- package/dist/components/avatar/AvatarFallback.svelte.d.ts +2 -2
- package/dist/components/avatar/AvatarImage.svelte +3 -3
- package/dist/components/avatar/AvatarImage.svelte.d.ts +3 -3
- package/dist/components/avatar/AvatarRoot.svelte +7 -7
- package/dist/components/avatar/AvatarRoot.svelte.d.ts +5 -5
- package/dist/components/badge/Badge.svelte +26 -11
- package/dist/components/badge/Badge.svelte.d.ts +8 -5
- package/dist/components/button/Button.svelte +263 -53
- package/dist/components/button/Button.svelte.d.ts +53 -11
- package/dist/components/card/Card.svelte +21 -32
- package/dist/components/card/Card.svelte.d.ts +6 -6
- package/dist/components/change-stats/ChangeStats.svelte +5 -6
- package/dist/components/change-stats/ChangeStats.svelte.d.ts +4 -4
- package/dist/components/changes-summary/ChangesSummary.svelte +20 -21
- package/dist/components/changes-summary/ChangesSummary.svelte.d.ts +6 -6
- package/dist/components/checkbox/Checkbox.svelte +37 -23
- package/dist/components/checkbox/Checkbox.svelte.d.ts +14 -7
- package/dist/components/choice-cards/ChoiceCards.svelte +145 -0
- package/dist/components/choice-cards/ChoiceCards.svelte.d.ts +29 -0
- package/dist/components/code/Code.svelte +3 -4
- package/dist/components/code/Code.svelte.d.ts +2 -2
- package/dist/components/collapsible/CollapsibleContent.svelte +8 -8
- package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +10 -5
- package/dist/components/collapsible/CollapsibleRoot.svelte +8 -5
- package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +10 -5
- package/dist/components/collapsible/CollapsibleTrigger.svelte +19 -10
- package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +20 -7
- package/dist/components/command/CommandDialog.svelte +3 -3
- package/dist/components/command/CommandDialog.svelte.d.ts +3 -3
- package/dist/components/command/CommandEmpty.svelte +8 -5
- package/dist/components/command/CommandEmpty.svelte.d.ts +10 -5
- package/dist/components/command/CommandFooter.svelte +2 -2
- package/dist/components/command/CommandFooter.svelte.d.ts +2 -2
- package/dist/components/command/CommandGroup.svelte +9 -6
- package/dist/components/command/CommandGroup.svelte.d.ts +12 -6
- package/dist/components/command/CommandInput.svelte +4 -1
- package/dist/components/command/CommandInput.svelte.d.ts +7 -4
- package/dist/components/command/CommandItem.svelte +15 -12
- package/dist/components/command/CommandItem.svelte.d.ts +18 -8
- package/dist/components/command/CommandList.svelte +7 -4
- package/dist/components/command/CommandList.svelte.d.ts +9 -5
- package/dist/components/command/CommandRoot.svelte +8 -5
- package/dist/components/command/CommandRoot.svelte.d.ts +10 -5
- package/dist/components/command/index.d.ts +3 -2
- package/dist/components/command/index.js +3 -2
- package/dist/components/command/styles.d.ts +3 -2
- package/dist/components/command/styles.js +13 -10
- package/dist/components/composer/ComposerAttachButton.svelte +5 -5
- package/dist/components/composer/ComposerAttachButton.svelte.d.ts +4 -4
- package/dist/components/composer/ComposerAttachment.svelte +11 -14
- package/dist/components/composer/ComposerAttachment.svelte.d.ts +2 -2
- package/dist/components/composer/ComposerAttachments.svelte +3 -3
- package/dist/components/composer/ComposerAttachments.svelte.d.ts +3 -3
- package/dist/components/composer/ComposerModelPicker.svelte +27 -29
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +9 -9
- package/dist/components/composer/ComposerRoot.svelte +26 -32
- package/dist/components/composer/ComposerRoot.svelte.d.ts +15 -15
- package/dist/components/composer/ComposerSubmit.svelte +14 -20
- package/dist/components/composer/ComposerSubmit.svelte.d.ts +4 -4
- package/dist/components/composer/ComposerTextarea.svelte +4 -4
- package/dist/components/composer/ComposerTextarea.svelte.d.ts +3 -3
- package/dist/components/composer/ComposerToggle.svelte +13 -15
- package/dist/components/composer/ComposerToggle.svelte.d.ts +4 -4
- package/dist/components/composer/ComposerToolbar.svelte +2 -2
- package/dist/components/composer/ComposerToolbar.svelte.d.ts +2 -2
- package/dist/components/composer/ComposerTray.svelte +78 -0
- package/dist/components/composer/ComposerTray.svelte.d.ts +15 -0
- package/dist/components/composer/index.d.ts +3 -1
- package/dist/components/composer/index.js +3 -2
- package/dist/components/conversation/ConversationContent.svelte +7 -6
- package/dist/components/conversation/ConversationContent.svelte.d.ts +4 -4
- package/dist/components/conversation/ConversationEmpty.svelte +6 -6
- package/dist/components/conversation/ConversationEmpty.svelte.d.ts +5 -5
- package/dist/components/conversation/ConversationRoot.svelte +4 -4
- package/dist/components/conversation/ConversationRoot.svelte.d.ts +4 -4
- package/dist/components/conversation/ConversationScrollButton.svelte +7 -7
- package/dist/components/conversation/ConversationScrollButton.svelte.d.ts +4 -4
- package/dist/components/dialog/ConfirmDialog.svelte +47 -16
- package/dist/components/dialog/ConfirmDialog.svelte.d.ts +14 -9
- package/dist/components/dialog/DialogBody.svelte +12 -4
- package/dist/components/dialog/DialogBody.svelte.d.ts +5 -3
- package/dist/components/dialog/DialogContent.svelte +16 -11
- package/dist/components/dialog/DialogContent.svelte.d.ts +21 -9
- package/dist/components/dialog/DialogDescription.svelte +7 -4
- package/dist/components/dialog/DialogDescription.svelte.d.ts +9 -5
- package/dist/components/dialog/DialogFooter.svelte +2 -2
- package/dist/components/dialog/DialogFooter.svelte.d.ts +2 -2
- package/dist/components/dialog/DialogHeader.svelte +2 -2
- package/dist/components/dialog/DialogHeader.svelte.d.ts +2 -2
- package/dist/components/dialog/DialogTitle.svelte +7 -4
- package/dist/components/dialog/DialogTitle.svelte.d.ts +9 -5
- package/dist/components/dialog/index.d.ts +5 -4
- package/dist/components/dialog/index.js +4 -3
- package/dist/components/dialog/styles.d.ts +8 -3
- package/dist/components/dialog/styles.js +11 -7
- package/dist/components/divider/Divider.svelte +6 -6
- package/dist/components/divider/Divider.svelte.d.ts +3 -3
- package/dist/components/empty-state/EmptyState.svelte +14 -10
- package/dist/components/empty-state/EmptyState.svelte.d.ts +5 -4
- package/dist/components/field/Field.svelte +92 -31
- package/dist/components/field/Field.svelte.d.ts +24 -11
- package/dist/components/field/context.d.ts +6 -3
- package/dist/components/frame/Frame.svelte +12 -13
- package/dist/components/frame/Frame.svelte.d.ts +7 -7
- package/dist/components/grid/Grid.svelte +17 -6
- package/dist/components/grid/Grid.svelte.d.ts +6 -6
- package/dist/components/heading/Heading.svelte +31 -8
- package/dist/components/heading/Heading.svelte.d.ts +6 -4
- package/dist/components/hover-card/HoverCardContent.svelte +7 -4
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +9 -5
- package/dist/components/hover-card/HoverCardRoot.svelte +2 -1
- package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +3 -2
- package/dist/components/hover-card/index.d.ts +2 -1
- package/dist/components/hover-card/index.js +2 -1
- package/dist/components/input/Input.svelte +63 -17
- package/dist/components/input/Input.svelte.d.ts +12 -5
- package/dist/components/kbd/Kbd.svelte +14 -9
- package/dist/components/kbd/Kbd.svelte.d.ts +2 -2
- package/dist/components/link/Link.svelte +12 -8
- package/dist/components/link/Link.svelte.d.ts +9 -6
- package/dist/components/list/ListItem.svelte +41 -0
- package/dist/components/list/ListItem.svelte.d.ts +10 -0
- package/dist/components/list/ListRoot.svelte +69 -0
- package/dist/components/list/ListRoot.svelte.d.ts +28 -0
- package/dist/components/list/context.d.ts +5 -0
- package/dist/components/list/context.js +8 -0
- package/dist/components/list/index.d.ts +5 -0
- package/dist/components/list/index.js +3 -0
- package/dist/components/markdown/Markdown.svelte +714 -0
- package/dist/components/markdown/Markdown.svelte.d.ts +80 -0
- package/dist/components/markdown/MarkdownBlock.svelte +231 -0
- package/dist/components/markdown/MarkdownBlock.svelte.d.ts +11 -0
- package/dist/components/markdown/MarkdownBlocks.svelte +115 -0
- package/dist/components/markdown/MarkdownBlocks.svelte.d.ts +15 -0
- package/dist/components/markdown/MarkdownCode.svelte +583 -0
- package/dist/components/markdown/MarkdownCode.svelte.d.ts +23 -0
- package/dist/components/markdown/MarkdownDiagram.svelte +310 -0
- package/dist/components/markdown/MarkdownDiagram.svelte.d.ts +6 -0
- package/dist/components/markdown/MarkdownFile.svelte +136 -0
- package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
- package/dist/components/markdown/MarkdownFootnotes.svelte +62 -0
- package/dist/components/markdown/MarkdownFootnotes.svelte.d.ts +8 -0
- package/dist/components/markdown/MarkdownFresh.svelte +69 -0
- package/dist/components/markdown/MarkdownFresh.svelte.d.ts +6 -0
- package/dist/components/markdown/MarkdownHtml.svelte +72 -0
- package/dist/components/markdown/MarkdownHtml.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownImage.svelte +150 -0
- package/dist/components/markdown/MarkdownImage.svelte.d.ts +8 -0
- package/dist/components/markdown/MarkdownInlines.svelte +225 -0
- package/dist/components/markdown/MarkdownInlines.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownLink.svelte +120 -0
- package/dist/components/markdown/MarkdownLink.svelte.d.ts +25 -0
- package/dist/components/markdown/MarkdownMath.svelte +138 -0
- package/dist/components/markdown/MarkdownMath.svelte.d.ts +7 -0
- package/dist/components/markdown/MarkdownTable.svelte +258 -0
- package/dist/components/markdown/MarkdownTable.svelte.d.ts +17 -0
- package/dist/components/markdown/caret.d.ts +14 -0
- package/dist/components/markdown/caret.js +67 -0
- package/dist/components/markdown/context.d.ts +93 -0
- package/dist/components/markdown/context.js +128 -0
- package/dist/components/markdown/copy.d.ts +13 -0
- package/dist/components/markdown/copy.js +74 -0
- package/dist/components/markdown/hidden.d.ts +12 -0
- package/dist/components/markdown/hidden.js +31 -0
- package/dist/components/markdown/kept.d.ts +32 -0
- package/dist/components/markdown/kept.js +71 -0
- package/dist/components/markdown/labels.d.ts +46 -0
- package/dist/components/markdown/labels.js +35 -0
- package/dist/components/markdown/save.d.ts +11 -0
- package/dist/components/markdown/save.js +58 -0
- package/dist/components/markdown/scrollable.d.ts +24 -0
- package/dist/components/markdown/scrollable.js +152 -0
- package/dist/components/markdown/static.d.ts +37 -0
- package/dist/components/markdown/static.js +233 -0
- package/dist/components/markdown/styles.d.ts +320 -0
- package/dist/components/markdown/styles.js +294 -0
- package/dist/components/menu/ContextMenuContent.svelte +8 -5
- package/dist/components/menu/ContextMenuContent.svelte.d.ts +10 -5
- package/dist/components/menu/ContextMenuTrigger.svelte +8 -5
- package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +10 -5
- package/dist/components/menu/MenuCheckboxItem.svelte +8 -5
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +11 -6
- package/dist/components/menu/MenuContent.svelte +7 -4
- package/dist/components/menu/MenuContent.svelte.d.ts +9 -5
- package/dist/components/menu/MenuItem.svelte +14 -11
- package/dist/components/menu/MenuItem.svelte.d.ts +18 -8
- package/dist/components/menu/MenuLabel.svelte +7 -4
- package/dist/components/menu/MenuLabel.svelte.d.ts +9 -5
- package/dist/components/menu/MenuRadioItem.svelte +26 -11
- package/dist/components/menu/MenuRadioItem.svelte.d.ts +20 -6
- package/dist/components/menu/MenuSeparator.svelte +6 -3
- package/dist/components/menu/MenuSeparator.svelte.d.ts +7 -4
- package/dist/components/menu/MenuSubContent.svelte +7 -4
- package/dist/components/menu/MenuSubContent.svelte.d.ts +9 -5
- package/dist/components/menu/MenuSubTrigger.svelte +9 -6
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +11 -6
- package/dist/components/menu/context-menu.d.ts +3 -1
- package/dist/components/menu/context-menu.js +2 -1
- package/dist/components/menu/index.d.ts +24 -0
- package/dist/components/menu/index.js +9 -6
- package/dist/components/message/MessageAction.svelte +26 -6
- package/dist/components/message/MessageAction.svelte.d.ts +13 -4
- package/dist/components/message/MessageActions.svelte +4 -4
- package/dist/components/message/MessageActions.svelte.d.ts +4 -4
- package/dist/components/message/MessageContent.svelte +5 -6
- package/dist/components/message/MessageContent.svelte.d.ts +3 -3
- package/dist/components/message/MessageCopy.svelte +74 -18
- package/dist/components/message/MessageCopy.svelte.d.ts +22 -6
- package/dist/components/message/MessageHeader.svelte +6 -6
- package/dist/components/message/MessageHeader.svelte.d.ts +3 -3
- package/dist/components/message/MessagePending.svelte +3 -3
- package/dist/components/message/MessagePending.svelte.d.ts +2 -2
- package/dist/components/message/MessageRoot.svelte +5 -5
- package/dist/components/message/MessageRoot.svelte.d.ts +5 -5
- package/dist/components/message/MessageTime.svelte +4 -4
- package/dist/components/message/MessageTime.svelte.d.ts +3 -3
- package/dist/components/notice/Notice.svelte +59 -19
- package/dist/components/notice/Notice.svelte.d.ts +13 -8
- package/dist/components/plan/Plan.svelte +28 -30
- package/dist/components/plan/Plan.svelte.d.ts +5 -5
- package/dist/components/popover/PopoverContent.svelte +7 -4
- package/dist/components/popover/PopoverContent.svelte.d.ts +9 -5
- package/dist/components/popover/index.d.ts +4 -3
- package/dist/components/popover/index.js +4 -3
- package/dist/components/progress/Progress.svelte +34 -36
- package/dist/components/progress/Progress.svelte.d.ts +3 -3
- package/dist/components/questionnaire/Questionnaire.svelte +36 -33
- package/dist/components/questionnaire/Questionnaire.svelte.d.ts +11 -11
- package/dist/components/queued-message/QueuedMessage.svelte +24 -17
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +10 -10
- package/dist/components/rail/RailItem.svelte +49 -53
- package/dist/components/rail/RailItem.svelte.d.ts +11 -9
- package/dist/components/rail/RailRoot.svelte +20 -6
- package/dist/components/rail/RailRoot.svelte.d.ts +3 -3
- package/dist/components/rail/RailSeparator.svelte +17 -0
- package/dist/components/rail/RailSeparator.svelte.d.ts +18 -0
- package/dist/components/rail/index.d.ts +2 -1
- package/dist/components/rail/index.js +2 -1
- package/dist/components/reasoning/ReasoningContent.svelte +6 -10
- package/dist/components/reasoning/ReasoningContent.svelte.d.ts +2 -2
- package/dist/components/reasoning/ReasoningRoot.svelte +6 -6
- package/dist/components/reasoning/ReasoningRoot.svelte.d.ts +6 -6
- package/dist/components/reasoning/ReasoningTrigger.svelte +5 -5
- package/dist/components/reasoning/ReasoningTrigger.svelte.d.ts +3 -3
- package/dist/components/resize-handle/ResizeHandle.svelte +12 -13
- package/dist/components/resize-handle/ResizeHandle.svelte.d.ts +10 -10
- package/dist/components/reveal/Reveal.svelte +16 -10
- package/dist/components/reveal/Reveal.svelte.d.ts +4 -4
- package/dist/components/reveal/revealed.js +13 -9
- package/dist/components/rolling-text/RollingText.svelte +3 -3
- package/dist/components/rolling-text/RollingText.svelte.d.ts +3 -3
- package/dist/components/search-button/SearchButton.svelte +92 -0
- package/dist/components/search-button/SearchButton.svelte.d.ts +13 -0
- package/dist/components/segmented/SegmentedControl.svelte +78 -32
- package/dist/components/segmented/SegmentedControl.svelte.d.ts +14 -5
- package/dist/components/select/Select.svelte +40 -15
- package/dist/components/select/Select.svelte.d.ts +21 -13
- package/dist/components/separator/Separator.svelte +4 -4
- package/dist/components/separator/Separator.svelte.d.ts +3 -3
- package/dist/components/settings-group/SettingsGroup.svelte +118 -0
- package/dist/components/settings-group/SettingsGroup.svelte.d.ts +19 -0
- package/dist/components/settings-group/context.d.ts +7 -0
- package/dist/components/settings-group/context.js +9 -0
- package/dist/components/settings-row/SettingsRow.svelte +185 -57
- package/dist/components/settings-row/SettingsRow.svelte.d.ts +39 -14
- package/dist/components/sheet/SheetContent.svelte +31 -11
- package/dist/components/sheet/SheetContent.svelte.d.ts +33 -9
- package/dist/components/sheet/index.d.ts +5 -4
- package/dist/components/sheet/index.js +4 -3
- package/dist/components/sheet/styles.d.ts +6 -0
- package/dist/components/sheet/styles.js +2 -0
- package/dist/components/shimmer/Shimmer.svelte +37 -24
- package/dist/components/shimmer/Shimmer.svelte.d.ts +3 -3
- package/dist/components/sidebar/SidebarContent.svelte +4 -4
- package/dist/components/sidebar/SidebarContent.svelte.d.ts +3 -3
- package/dist/components/sidebar/SidebarFolder.svelte +147 -0
- package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
- package/dist/components/sidebar/SidebarFooter.svelte +3 -3
- package/dist/components/sidebar/SidebarFooter.svelte.d.ts +2 -2
- package/dist/components/sidebar/SidebarGroup.svelte +41 -37
- package/dist/components/sidebar/SidebarGroup.svelte.d.ts +8 -8
- package/dist/components/sidebar/SidebarHeader.svelte +15 -9
- package/dist/components/sidebar/SidebarHeader.svelte.d.ts +7 -4
- package/dist/components/sidebar/SidebarItem.svelte +64 -45
- package/dist/components/sidebar/SidebarItem.svelte.d.ts +15 -10
- package/dist/components/sidebar/SidebarRoot.svelte +62 -0
- package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
- package/dist/components/sidebar/SidebarSwitcher.svelte +28 -0
- package/dist/components/sidebar/SidebarSwitcher.svelte.d.ts +11 -0
- package/dist/components/sidebar/depth.d.ts +8 -0
- package/dist/components/sidebar/depth.js +14 -0
- package/dist/components/sidebar/index.d.ts +7 -1
- package/dist/components/sidebar/index.js +4 -1
- package/dist/components/skeleton/Skeleton.svelte +31 -20
- package/dist/components/skeleton/Skeleton.svelte.d.ts +5 -5
- package/dist/components/slider/Slider.svelte +24 -23
- package/dist/components/slider/Slider.svelte.d.ts +13 -13
- package/dist/components/spinner/Spinner.svelte +8 -14
- package/dist/components/spinner/Spinner.svelte.d.ts +3 -3
- package/dist/components/stack/Stack.svelte +19 -8
- package/dist/components/stack/Stack.svelte.d.ts +8 -8
- package/dist/components/status-indicator/StatusIndicator.svelte +6 -5
- package/dist/components/status-indicator/StatusIndicator.svelte.d.ts +4 -4
- package/dist/components/suggestions/SuggestionsItem.svelte +8 -8
- package/dist/components/suggestions/SuggestionsItem.svelte.d.ts +3 -3
- package/dist/components/suggestions/SuggestionsRoot.svelte +5 -5
- package/dist/components/suggestions/SuggestionsRoot.svelte.d.ts +5 -5
- package/dist/components/switch/Switch.svelte +27 -21
- package/dist/components/switch/Switch.svelte.d.ts +8 -6
- package/dist/components/tab-strip/TabStrip.svelte +421 -0
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
- package/dist/components/tabs/Tabs.svelte +83 -33
- package/dist/components/tabs/Tabs.svelte.d.ts +15 -5
- package/dist/components/text/Text.svelte +63 -31
- package/dist/components/text/Text.svelte.d.ts +18 -12
- package/dist/components/textarea/Textarea.svelte +5 -5
- package/dist/components/textarea/Textarea.svelte.d.ts +5 -5
- package/dist/components/theme/Theme.svelte +4 -4
- package/dist/components/theme/Theme.svelte.d.ts +4 -4
- package/dist/components/toast/Toaster.svelte +39 -32
- package/dist/components/toast/Toaster.svelte.d.ts +2 -2
- package/dist/components/toast/toasts.svelte.d.ts +52 -15
- package/dist/components/toast/toasts.svelte.js +45 -20
- package/dist/components/toggle/Toggle.svelte +11 -8
- package/dist/components/toggle/Toggle.svelte.d.ts +15 -7
- package/dist/components/toggle-group/ToggleGroupItem.svelte +9 -6
- package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -6
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +17 -14
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +13 -12
- package/dist/components/tool/ToolContent.svelte +5 -10
- package/dist/components/tool/ToolContent.svelte.d.ts +2 -2
- package/dist/components/tool/ToolInput.svelte +3 -3
- package/dist/components/tool/ToolInput.svelte.d.ts +3 -3
- package/dist/components/tool/ToolOutput.svelte +4 -4
- package/dist/components/tool/ToolOutput.svelte.d.ts +4 -4
- package/dist/components/tool/ToolRoot.svelte +7 -7
- package/dist/components/tool/ToolRoot.svelte.d.ts +7 -7
- package/dist/components/tool/ToolSection.svelte +8 -9
- package/dist/components/tool/ToolSection.svelte.d.ts +4 -4
- package/dist/components/tool/ToolTrigger.svelte +14 -13
- package/dist/components/tool/ToolTrigger.svelte.d.ts +4 -4
- package/dist/components/tooltip/TooltipContent.svelte +12 -9
- package/dist/components/tooltip/TooltipContent.svelte.d.ts +12 -6
- package/dist/components/tooltip/TooltipRoot.svelte +7 -4
- package/dist/components/tooltip/TooltipRoot.svelte.d.ts +8 -4
- package/dist/components/tooltip/TooltipTrigger.svelte +2 -1
- package/dist/components/tooltip/TooltipTrigger.svelte.d.ts +3 -2
- package/dist/components/tooltip/index.d.ts +2 -1
- package/dist/components/tooltip/index.js +2 -1
- package/dist/components/work-fold/WorkFold.svelte +9 -13
- package/dist/components/work-fold/WorkFold.svelte.d.ts +4 -4
- package/dist/index.d.ts +30 -12
- package/dist/index.js +24 -10
- package/dist/internal/Chevron.svelte +1 -1
- package/dist/internal/Chevron.svelte.d.ts +1 -1
- package/dist/internal/Code.svelte +9 -5
- package/dist/internal/Code.svelte.d.ts +3 -3
- package/dist/internal/Collapse.svelte +4 -4
- package/dist/internal/Collapse.svelte.d.ts +4 -4
- package/dist/internal/Glyph.svelte +19 -1
- package/dist/internal/Glyph.svelte.d.ts +9 -2
- package/dist/internal/Tile.svelte +22 -42
- package/dist/internal/Tile.svelte.d.ts +5 -5
- package/dist/internal/complete.d.ts +8 -0
- package/dist/internal/complete.js +1 -0
- package/dist/internal/control.d.ts +4 -4
- package/dist/internal/control.js +20 -17
- package/dist/internal/icon.d.ts +9 -0
- package/dist/internal/icon.js +1 -0
- package/dist/internal/icons.css +14 -0
- package/dist/internal/json.d.ts +1 -1
- package/dist/internal/layer.d.ts +6 -6
- package/dist/internal/layer.js +17 -14
- package/dist/internal/layout.d.ts +1 -1
- package/dist/internal/layout.js +6 -0
- package/dist/internal/loose.d.ts +22 -0
- package/dist/internal/loose.js +4 -0
- package/dist/internal/markers.stylex.d.ts +12 -0
- package/dist/internal/markers.stylex.js +6 -0
- package/dist/internal/plugin-order.d.ts +8 -0
- package/dist/internal/plugin-order.js +16 -0
- package/dist/internal/responsive.d.ts +1 -1
- package/dist/internal/roving.d.ts +1 -1
- package/dist/internal/roving.js +5 -2
- package/dist/internal/shared.d.ts +8 -1
- package/dist/internal/shared.js +21 -5
- package/dist/internal/sx.d.ts +5 -5
- package/dist/internal/toggle.d.ts +1 -2
- package/dist/internal/toggle.js +8 -12
- package/dist/internal/tooltip-trigger.d.ts +9 -0
- package/dist/internal/tooltip-trigger.js +19 -0
- package/dist/internal/visible.d.ts +32 -0
- package/dist/internal/visible.js +44 -0
- package/dist/markdown/ast.d.ts +209 -0
- package/dist/markdown/ast.js +10 -0
- package/dist/markdown/blocks.d.ts +178 -0
- package/dist/markdown/blocks.js +1489 -0
- package/dist/markdown/code-info.d.ts +10 -0
- package/dist/markdown/code-info.js +16 -0
- package/dist/markdown/common.d.ts +25 -0
- package/dist/markdown/common.js +107 -0
- package/dist/markdown/diagrams.d.ts +2 -0
- package/dist/markdown/diagrams.js +18 -0
- package/dist/markdown/file-paths.d.ts +29 -0
- package/dist/markdown/file-paths.js +80 -0
- package/dist/markdown/files.d.ts +16 -0
- package/dist/markdown/files.js +133 -0
- package/dist/markdown/highlight.d.ts +30 -0
- package/dist/markdown/highlight.js +127 -0
- package/dist/markdown/html.d.ts +14 -0
- package/dist/markdown/html.js +289 -0
- package/dist/markdown/images.d.ts +15 -0
- package/dist/markdown/images.js +45 -0
- package/dist/markdown/index.d.ts +12 -0
- package/dist/markdown/index.js +5 -0
- package/dist/markdown/inlines.d.ts +48 -0
- package/dist/markdown/inlines.js +1714 -0
- package/dist/markdown/math.d.ts +2 -0
- package/dist/markdown/math.js +22 -0
- package/dist/markdown/parse.d.ts +81 -0
- package/dist/markdown/parse.js +204 -0
- package/dist/markdown/plugin.d.ts +179 -0
- package/dist/markdown/plugin.js +160 -0
- package/dist/markdown/sanitize.d.ts +78 -0
- package/dist/markdown/sanitize.js +522 -0
- package/dist/markdown/share.d.ts +12 -0
- package/dist/markdown/share.js +59 -0
- package/dist/markdown/table.d.ts +13 -0
- package/dist/markdown/table.js +60 -0
- package/dist/markers.stylex.d.ts +13 -0
- package/dist/markers.stylex.js +11 -0
- package/dist/preset.d.ts +44 -20
- package/dist/preset.js +169 -51
- package/dist/tokens.stylex.d.ts +57 -37
- package/dist/tokens.stylex.js +113 -62
- package/dist/typography.d.ts +55 -0
- package/dist/typography.js +63 -0
- package/dist/visually-hidden.d.ts +18 -0
- package/dist/visually-hidden.js +21 -0
- package/dist/vite.d.ts +9 -3
- package/dist/vite.js +27 -2
- package/package.json +57 -6
- package/skills/building-ui/SKILL.md +385 -0
- package/skills/building-ui/references/components.md +211 -0
- package/skills/markdown/SKILL.md +452 -0
- package/skills/markdown/references/plugins.md +103 -0
- package/skills/setup/SKILL.md +199 -0
- package/skills/styling/SKILL.md +318 -0
- package/skills/theming/SKILL.md +277 -0
- package/dist/internal/loop.d.ts +0 -35
- package/dist/internal/loop.js +0 -72
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<!-- Raw HTML that the allowlist kept, as real elements. -->
|
|
2
|
+
<script lang="ts" module>
|
|
3
|
+
import { attrs } from '../../internal/sx.js';
|
|
4
|
+
import { VOID, imageOf, type HtmlNode } from '../../markdown/sanitize.js';
|
|
5
|
+
import MarkdownInlines from './MarkdownInlines.svelte';
|
|
6
|
+
import MarkdownLink, { wordsOf } from './MarkdownLink.svelte';
|
|
7
|
+
import { scrollable } from './scrollable.js';
|
|
8
|
+
import { prose } from './styles.js';
|
|
9
|
+
import MarkdownBlock from './MarkdownBlock.svelte';
|
|
10
|
+
import Self from './MarkdownHtml.svelte';
|
|
11
|
+
|
|
12
|
+
export type MarkdownHtmlProps = { nodes: HtmlNode[] };
|
|
13
|
+
|
|
14
|
+
const htmlStyles: Record<string, unknown> = {
|
|
15
|
+
code: prose.code,
|
|
16
|
+
kbd: prose.kbd,
|
|
17
|
+
mark: prose.mark,
|
|
18
|
+
strong: prose.strong,
|
|
19
|
+
b: prose.strong,
|
|
20
|
+
em: prose.emphasis,
|
|
21
|
+
i: prose.emphasis,
|
|
22
|
+
del: prose.delete,
|
|
23
|
+
s: prose.delete,
|
|
24
|
+
hr: prose.rule,
|
|
25
|
+
blockquote: prose.blockquote,
|
|
26
|
+
details: prose.details,
|
|
27
|
+
summary: prose.summary,
|
|
28
|
+
th: [prose.cell, prose.headCell, prose.rawCell],
|
|
29
|
+
td: [prose.cell, prose.rawCell]
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Whether a table's first row is of plain cells, not headings. */
|
|
33
|
+
function headless(table: HtmlNode): boolean {
|
|
34
|
+
let node: HtmlNode | undefined = table;
|
|
35
|
+
// Down through `thead` or `tbody` to the first row's first cell
|
|
36
|
+
while (node && node.type === 'element' && node.tag !== 'td' && node.tag !== 'th')
|
|
37
|
+
node = node.children.find((child) => child.type === 'element');
|
|
38
|
+
return !(node && node.type === 'element' && node.tag === 'th');
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
let { nodes }: MarkdownHtmlProps = $props();
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
{#each nodes as node, i (i)}
|
|
47
|
+
{#if node.type === 'text'}
|
|
48
|
+
{node.value}
|
|
49
|
+
{:else if node.type === 'markdown'}
|
|
50
|
+
<MarkdownBlock node={node.block} />
|
|
51
|
+
{:else if node.tag === 'img' || node.tag === 'video'}
|
|
52
|
+
<!-- Drawn as a Markdown image is, so a plugin that gates images gates this one too -->
|
|
53
|
+
<MarkdownInlines nodes={[imageOf(node)]} />
|
|
54
|
+
{:else if node.tag === 'a' && node.attrs.href}
|
|
55
|
+
<MarkdownLink href={node.attrs.href} title={node.attrs.title} label={wordsOf(node.children)}>
|
|
56
|
+
<Self nodes={node.children} />
|
|
57
|
+
</MarkdownLink>
|
|
58
|
+
{:else if node.tag === 'table'}
|
|
59
|
+
<!-- In the frame a Markdown table has, so a wide one scrolls rather than pushing the reply wide -->
|
|
60
|
+
<div use:scrollable {...attrs([prose.block, prose.tableFrame])}>
|
|
61
|
+
<table {...node.attrs} {...attrs([prose.table, headless(node) && prose.rawTableHeadless])}>
|
|
62
|
+
<Self nodes={node.children} />
|
|
63
|
+
</table>
|
|
64
|
+
</div>
|
|
65
|
+
{:else if VOID.has(node.tag)}
|
|
66
|
+
<svelte:element this={node.tag} {...node.attrs} {...attrs([htmlStyles[node.tag] as never])} />
|
|
67
|
+
{:else}
|
|
68
|
+
<svelte:element this={node.tag} {...node.attrs} {...attrs([htmlStyles[node.tag] as never])}>
|
|
69
|
+
<Self nodes={node.children} />
|
|
70
|
+
</svelte:element>
|
|
71
|
+
{/if}
|
|
72
|
+
{/each}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type HtmlNode } from '../../markdown/sanitize.js';
|
|
2
|
+
export type MarkdownHtmlProps = {
|
|
3
|
+
nodes: HtmlNode[];
|
|
4
|
+
};
|
|
5
|
+
declare const MarkdownHtml: import("svelte").Component<MarkdownHtmlProps, {}, "">;
|
|
6
|
+
type MarkdownHtml = ReturnType<typeof MarkdownHtml>;
|
|
7
|
+
export default MarkdownHtml;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
An image that loads only when allowed or asked for. One the app has not allowed shows as a
|
|
3
|
+
button naming the host it would be fetched from; pressing it loads the image, and any other
|
|
4
|
+
with the same address.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts" module>
|
|
7
|
+
import * as stylex from '@stylexjs/stylex';
|
|
8
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
9
|
+
import Glyph from '../../internal/Glyph.svelte';
|
|
10
|
+
import { attrs } from '../../internal/sx.js';
|
|
11
|
+
import type { Image } from '../../markdown/ast.js';
|
|
12
|
+
import { readUrl } from '../../markdown/plugin.js';
|
|
13
|
+
import { colors, motion, radius } from '../../tokens.stylex.js';
|
|
14
|
+
import { media } from '../../media.stylex.js';
|
|
15
|
+
import { getMarkdownContext } from './context.js';
|
|
16
|
+
import { prose } from './styles.js';
|
|
17
|
+
|
|
18
|
+
export type MarkdownImageProps = {
|
|
19
|
+
node: Image;
|
|
20
|
+
allow: (url: string) => boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Addresses the person has asked to load, on this page. */
|
|
24
|
+
const asked = new SvelteSet<string>();
|
|
25
|
+
|
|
26
|
+
const styles = stylex.create({
|
|
27
|
+
ask: {
|
|
28
|
+
display: 'inline-flex',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
gap: '0.375em',
|
|
31
|
+
maxWidth: '100%',
|
|
32
|
+
margin: 0,
|
|
33
|
+
paddingBlock: '0.25em',
|
|
34
|
+
paddingInline: '0.5em',
|
|
35
|
+
borderWidth: 0,
|
|
36
|
+
borderRadius: radius.item,
|
|
37
|
+
backgroundColor: {
|
|
38
|
+
default: colors.fillSunken,
|
|
39
|
+
':hover': { default: null, [media.hover]: colors.fillSelected }
|
|
40
|
+
},
|
|
41
|
+
color: colors.textMuted,
|
|
42
|
+
fontFamily: 'inherit',
|
|
43
|
+
fontSize: '0.875em',
|
|
44
|
+
lineHeight: 1.4,
|
|
45
|
+
textAlign: 'start',
|
|
46
|
+
cursor: 'pointer',
|
|
47
|
+
appearance: 'none',
|
|
48
|
+
outlineStyle: 'solid',
|
|
49
|
+
outlineWidth: { default: '1px', ':focus-visible': '2px' },
|
|
50
|
+
outlineColor: { default: 'transparent', ':focus-visible': colors.focusRing },
|
|
51
|
+
outlineOffset: { default: '-1px', ':focus-visible': '2px' },
|
|
52
|
+
transitionProperty: 'background-color',
|
|
53
|
+
transitionDuration: { default: '0s', [media.motion]: motion.fast }
|
|
54
|
+
},
|
|
55
|
+
icon: { flexShrink: 0 },
|
|
56
|
+
host: { color: colors.text, overflowWrap: 'anywhere' }
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function hostOf(url: string): string | null {
|
|
60
|
+
try {
|
|
61
|
+
return new URL(url, typeof location === 'undefined' ? 'http://localhost' : location.href)
|
|
62
|
+
.host;
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<script lang="ts">
|
|
70
|
+
let { node, allow }: MarkdownImageProps = $props();
|
|
71
|
+
|
|
72
|
+
const md = getMarkdownContext();
|
|
73
|
+
|
|
74
|
+
// The address as written, read as a browser reads it: what the app's `allow` is asked
|
|
75
|
+
// about, and what the button names
|
|
76
|
+
const address = $derived(readUrl(node.url).url);
|
|
77
|
+
// What the app's policy makes of it: null to refuse it, or the address to request, which
|
|
78
|
+
// may be another, such as a proxy's
|
|
79
|
+
const src = $derived(md.links.image(node.url, node));
|
|
80
|
+
const load = $derived(src !== null && (allow(address) || asked.has(src)));
|
|
81
|
+
const host = $derived(hostOf(address));
|
|
82
|
+
// A failure belongs to one address: another address gets its own try
|
|
83
|
+
let failedSrc = $state<string | null>(null);
|
|
84
|
+
const failed = $derived(failedSrc !== null && failedSrc === src);
|
|
85
|
+
let image = $state<HTMLImageElement | HTMLVideoElement | null>(null);
|
|
86
|
+
let focusImage = false;
|
|
87
|
+
|
|
88
|
+
// The button that was pressed is gone once the image shows; focus goes to the image
|
|
89
|
+
$effect(() => {
|
|
90
|
+
if (image && focusImage) {
|
|
91
|
+
focusImage = false;
|
|
92
|
+
image.focus({ preventScroll: true });
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
{#if src === null || failed}
|
|
98
|
+
{node.alt}
|
|
99
|
+
{:else if load && node.video}
|
|
100
|
+
<video
|
|
101
|
+
{src}
|
|
102
|
+
controls
|
|
103
|
+
preload="metadata"
|
|
104
|
+
aria-label={node.alt || node.title || md.labels.video}
|
|
105
|
+
title={node.title ?? undefined}
|
|
106
|
+
width={node.width}
|
|
107
|
+
height={node.height}
|
|
108
|
+
bind:this={image}
|
|
109
|
+
tabindex="-1"
|
|
110
|
+
onerror={() => (failedSrc = src)}
|
|
111
|
+
{...attrs([prose.image])}
|
|
112
|
+
></video>
|
|
113
|
+
{:else if load}
|
|
114
|
+
<img
|
|
115
|
+
{src}
|
|
116
|
+
alt={node.alt}
|
|
117
|
+
title={node.title ?? undefined}
|
|
118
|
+
width={node.width}
|
|
119
|
+
height={node.height}
|
|
120
|
+
loading="lazy"
|
|
121
|
+
bind:this={image}
|
|
122
|
+
tabindex="-1"
|
|
123
|
+
onerror={() => (failedSrc = src)}
|
|
124
|
+
{...attrs([prose.image])}
|
|
125
|
+
/>
|
|
126
|
+
{:else}
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
data-markdown-image-ask
|
|
130
|
+
title={node.url}
|
|
131
|
+
onclick={(event) => {
|
|
132
|
+
// Inside a link, pressing this must not also follow the link
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
focusImage = true;
|
|
136
|
+
asked.add(src);
|
|
137
|
+
}}
|
|
138
|
+
{...attrs([styles.ask])}
|
|
139
|
+
>
|
|
140
|
+
<Glyph name="globe" size={14} {...attrs([styles.icon])} />
|
|
141
|
+
<span>
|
|
142
|
+
<!-- Only the host, which the address gives: words the writer chose (the alt text) could
|
|
143
|
+
be made to read as another host -->
|
|
144
|
+
{node.video ? md.labels.loadVideo : md.labels.loadImage}
|
|
145
|
+
<span {...attrs([styles.host])}
|
|
146
|
+
>{host === null ? md.labels.anotherSite : host || md.labels.thisApp}</span
|
|
147
|
+
>
|
|
148
|
+
</span>
|
|
149
|
+
</button>
|
|
150
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Image } from '../../markdown/ast.js';
|
|
2
|
+
export type MarkdownImageProps = {
|
|
3
|
+
node: Image;
|
|
4
|
+
allow: (url: string) => boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const MarkdownImage: import("svelte").Component<MarkdownImageProps, {}, "">;
|
|
7
|
+
type MarkdownImage = ReturnType<typeof MarkdownImage>;
|
|
8
|
+
export default MarkdownImage;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A block's inline content: text, emphasis, code, links, images, footnote references, and raw
|
|
3
|
+
HTML that the allowlist kept, paired into elements.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts" module>
|
|
6
|
+
import { attrs, classes } from '../../internal/sx.js';
|
|
7
|
+
import { VOID, imageOf, type RenderInline } from '../../markdown/sanitize.js';
|
|
8
|
+
import Link from '../link/Link.svelte';
|
|
9
|
+
import { getMarkdownContext } from './context.js';
|
|
10
|
+
import { prose } from './styles.js';
|
|
11
|
+
import MarkdownFresh from './MarkdownFresh.svelte';
|
|
12
|
+
import MarkdownLink, { wordsOf } from './MarkdownLink.svelte';
|
|
13
|
+
import Self from './MarkdownInlines.svelte';
|
|
14
|
+
|
|
15
|
+
export type MarkdownInlinesProps = { nodes: RenderInline[] };
|
|
16
|
+
|
|
17
|
+
const NEWLINE = '\n';
|
|
18
|
+
|
|
19
|
+
/** Raw HTML elements that take one of Narvi's own looks. */
|
|
20
|
+
const htmlStyles: Record<string, unknown> = {
|
|
21
|
+
code: prose.code,
|
|
22
|
+
kbd: prose.kbd,
|
|
23
|
+
mark: prose.mark,
|
|
24
|
+
strong: prose.strong,
|
|
25
|
+
b: prose.strong,
|
|
26
|
+
em: prose.emphasis,
|
|
27
|
+
i: prose.emphasis,
|
|
28
|
+
del: prose.delete,
|
|
29
|
+
s: prose.delete,
|
|
30
|
+
strike: prose.delete
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Worked out once: these never change, so an element that takes one needs nothing to
|
|
34
|
+
// keep it up to date
|
|
35
|
+
const codeClass = classes(prose.code);
|
|
36
|
+
const strongClass = classes(prose.strong);
|
|
37
|
+
const emphasisClass = classes(prose.emphasis);
|
|
38
|
+
|
|
39
|
+
/** Whether a node holds one run of text and nothing else, as most bold and italics do. */
|
|
40
|
+
function onlyText<N extends { children: RenderInline[] }>(
|
|
41
|
+
node: N
|
|
42
|
+
): node is N & { children: [Extract<RenderInline, { type: 'text' }>] } {
|
|
43
|
+
return node.children.length === 1 && node.children[0]!.type === 'text';
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<script lang="ts">
|
|
48
|
+
let { nodes }: MarkdownInlinesProps = $props();
|
|
49
|
+
|
|
50
|
+
const md = getMarkdownContext();
|
|
51
|
+
// Asked once, when this is made: text drawn while the reply streams fades in as it arrives,
|
|
52
|
+
// and goes on being drawn the same way once the reply is done, so nothing is drawn again
|
|
53
|
+
const fading = md.fade();
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
{#snippet link(href: string, title: string | null | undefined, children: RenderInline[])}
|
|
57
|
+
<MarkdownLink {href} {title} label={wordsOf(children)}>
|
|
58
|
+
<Self nodes={children} />
|
|
59
|
+
</MarkdownLink>
|
|
60
|
+
{/snippet}
|
|
61
|
+
|
|
62
|
+
<!-- Narvi's own drawing of a node: what shows when no plugin takes it, or when a plugin's component fails -->
|
|
63
|
+
{#snippet standard(node: RenderInline)}
|
|
64
|
+
{#if node.type === 'text'}
|
|
65
|
+
{node.value}
|
|
66
|
+
{:else if node.type === 'softBreak'}
|
|
67
|
+
{#if md.breaks()}<br />{:else}{NEWLINE}{/if}
|
|
68
|
+
{:else if node.type === 'break'}
|
|
69
|
+
<br />
|
|
70
|
+
{:else if node.type === 'strong'}
|
|
71
|
+
<strong {...attrs([prose.strong])}><Self nodes={node.children} /></strong>
|
|
72
|
+
{:else if node.type === 'emphasis'}
|
|
73
|
+
<em {...attrs([prose.emphasis])}><Self nodes={node.children} /></em>
|
|
74
|
+
{:else if node.type === 'delete'}
|
|
75
|
+
<del {...attrs([prose.delete])}><Self nodes={node.children} /></del>
|
|
76
|
+
{:else if node.type === 'inlineCode'}
|
|
77
|
+
<code {...attrs([prose.code])}>{node.value}</code>
|
|
78
|
+
{:else if node.type === 'inlineMath'}
|
|
79
|
+
<code {...attrs([prose.code])}>{node.value}</code>
|
|
80
|
+
{:else if node.type === 'custom'}
|
|
81
|
+
<Self nodes={node.children} />
|
|
82
|
+
{:else if node.type === 'link'}
|
|
83
|
+
{@const href = node.pending ? null : md.links.href(node.url, node)}
|
|
84
|
+
{#if node.pending}
|
|
85
|
+
<Link data-markdown-pending><Self nodes={node.children} /></Link>
|
|
86
|
+
{:else if href === null}
|
|
87
|
+
<Self nodes={node.children} />
|
|
88
|
+
{:else}
|
|
89
|
+
{@render link(href, node.title, node.children)}
|
|
90
|
+
{/if}
|
|
91
|
+
{:else if node.type === 'image'}
|
|
92
|
+
{@const src = md.links.image(node.url, node)}
|
|
93
|
+
{#if src === null}
|
|
94
|
+
{node.alt}
|
|
95
|
+
{:else if node.video}
|
|
96
|
+
<!-- Nothing of it is fetched until it is played -->
|
|
97
|
+
<video
|
|
98
|
+
{src}
|
|
99
|
+
controls
|
|
100
|
+
preload="none"
|
|
101
|
+
aria-label={node.alt || node.title || md.labels.video}
|
|
102
|
+
title={node.title ?? undefined}
|
|
103
|
+
width={node.width}
|
|
104
|
+
height={node.height}
|
|
105
|
+
{...attrs([prose.image])}
|
|
106
|
+
></video>
|
|
107
|
+
{:else}
|
|
108
|
+
<img
|
|
109
|
+
{src}
|
|
110
|
+
alt={node.alt}
|
|
111
|
+
title={node.title ?? undefined}
|
|
112
|
+
width={node.width}
|
|
113
|
+
height={node.height}
|
|
114
|
+
loading="lazy"
|
|
115
|
+
{...attrs([prose.image])}
|
|
116
|
+
/>
|
|
117
|
+
{/if}
|
|
118
|
+
{:else if node.type === 'footnoteReference'}
|
|
119
|
+
{@const note = md.footnote(node)}
|
|
120
|
+
{#if note.number > 0}
|
|
121
|
+
{@const label = node.label.toLowerCase()}
|
|
122
|
+
<sup {...attrs([prose.footnoteRef])}>
|
|
123
|
+
<!-- The footnote links back to the first reference to it, which alone has the id -->
|
|
124
|
+
<Link
|
|
125
|
+
href="#{md.id}-fn-{label}"
|
|
126
|
+
id={note.first ? `${md.id}-fnref-${label}` : undefined}
|
|
127
|
+
onclick={(event: MouseEvent) => {
|
|
128
|
+
// Within the document, without touching the address: an app may route by hash
|
|
129
|
+
if (md.reveal(`${md.id}-fn-${label}`)) event.preventDefault();
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{note.number}
|
|
133
|
+
</Link>
|
|
134
|
+
</sup>
|
|
135
|
+
{:else}
|
|
136
|
+
[^{node.label}]
|
|
137
|
+
{/if}
|
|
138
|
+
{:else if node.type === 'htmlElement'}
|
|
139
|
+
{#if node.tag === 'img' || node.tag === 'video'}
|
|
140
|
+
<!-- Drawn as a Markdown image is, so a plugin that gates images gates this one too -->
|
|
141
|
+
<Self nodes={[imageOf(node)]} />
|
|
142
|
+
{:else if node.tag === 'a' && node.attrs.href}
|
|
143
|
+
{@render link(node.attrs.href, node.attrs.title, node.children)}
|
|
144
|
+
{:else if VOID.has(node.tag)}
|
|
145
|
+
<svelte:element this={node.tag} {...node.attrs} {...attrs([htmlStyles[node.tag] as never])} />
|
|
146
|
+
{:else}
|
|
147
|
+
<svelte:element this={node.tag} {...node.attrs} {...attrs([htmlStyles[node.tag] as never])}>
|
|
148
|
+
<Self nodes={node.children} />
|
|
149
|
+
</svelte:element>
|
|
150
|
+
{/if}
|
|
151
|
+
{/if}
|
|
152
|
+
{/snippet}
|
|
153
|
+
|
|
154
|
+
<!--
|
|
155
|
+
Most of what a reply holds is plain text, bold, italics and inline code. Those are drawn
|
|
156
|
+
here directly, in one step each: sent through the snippet above, and the test for a
|
|
157
|
+
plugin's component before it, every word of a long thread would leave three more layers of
|
|
158
|
+
bookkeeping behind it, and a thread's memory is mostly that.
|
|
159
|
+
-->
|
|
160
|
+
{#if fading}
|
|
161
|
+
{@render arriving()}
|
|
162
|
+
{:else if nodes.length === 1 && nodes[0]!.type === 'text' && !md.component('text')}
|
|
163
|
+
<!-- One run of text and nothing else: a list item, a table cell, a short heading -->
|
|
164
|
+
{nodes[0].value}
|
|
165
|
+
{:else}
|
|
166
|
+
{@render each()}
|
|
167
|
+
{/if}
|
|
168
|
+
|
|
169
|
+
<!-- While the reply streams with `animated`: the same, with text that fades in as it arrives -->
|
|
170
|
+
{#snippet arriving()}
|
|
171
|
+
{#each nodes as node, i (i)}
|
|
172
|
+
{#if node.type === 'text' && !md.component('text')}
|
|
173
|
+
<MarkdownFresh value={node.value} />
|
|
174
|
+
{:else if node.type === 'inlineCode' && !md.component('inlineCode')}
|
|
175
|
+
<code class={codeClass}><MarkdownFresh value={node.value} /></code>
|
|
176
|
+
{:else if node.type === 'strong' && onlyText(node) && !md.component('strong') && !md.component('text')}
|
|
177
|
+
<strong class={strongClass}><MarkdownFresh value={node.children[0].value} /></strong>
|
|
178
|
+
{:else if node.type === 'emphasis' && onlyText(node) && !md.component('emphasis') && !md.component('text')}
|
|
179
|
+
<em class={emphasisClass}><MarkdownFresh value={node.children[0].value} /></em>
|
|
180
|
+
{:else}
|
|
181
|
+
{@render general(node)}
|
|
182
|
+
{/if}
|
|
183
|
+
{/each}
|
|
184
|
+
{/snippet}
|
|
185
|
+
|
|
186
|
+
{#snippet each()}
|
|
187
|
+
{#each nodes as node, i (i)}
|
|
188
|
+
{#if node.type === 'text' && !md.component('text')}
|
|
189
|
+
{node.value}
|
|
190
|
+
{:else if node.type === 'inlineCode' && !md.component('inlineCode')}
|
|
191
|
+
<code class={codeClass}>{node.value}</code>
|
|
192
|
+
{:else if node.type === 'strong' && onlyText(node) && !md.component('strong') && !md.component('text')}
|
|
193
|
+
<strong class={strongClass}>{node.children[0].value}</strong>
|
|
194
|
+
{:else if node.type === 'emphasis' && onlyText(node) && !md.component('emphasis') && !md.component('text')}
|
|
195
|
+
<em class={emphasisClass}>{node.children[0].value}</em>
|
|
196
|
+
{:else if node.type === 'link' && !md.component('link')}
|
|
197
|
+
{@const href = node.pending ? null : md.links.href(node.url, node)}
|
|
198
|
+
{#if node.pending}
|
|
199
|
+
<!-- Its address is still being written: a link already, with nowhere to go yet -->
|
|
200
|
+
<Link data-markdown-pending><Self nodes={node.children} /></Link>
|
|
201
|
+
{:else if href === null}
|
|
202
|
+
<Self nodes={node.children} />
|
|
203
|
+
{:else}
|
|
204
|
+
{@render link(href, node.title, node.children)}
|
|
205
|
+
{/if}
|
|
206
|
+
{:else}
|
|
207
|
+
{@render general(node)}
|
|
208
|
+
{/if}
|
|
209
|
+
{/each}
|
|
210
|
+
{/snippet}
|
|
211
|
+
|
|
212
|
+
{#snippet general(node: RenderInline)}
|
|
213
|
+
{@const Override = md.component(node.type === 'custom' ? node.name : node.type)}
|
|
214
|
+
{#if Override}
|
|
215
|
+
<!-- A plugin's component that throws takes down its own node, not the message -->
|
|
216
|
+
<svelte:boundary>
|
|
217
|
+
<Override.component node={node as never} {...Override.props}>
|
|
218
|
+
{#if 'children' in node && node.type !== 'image'}<Self nodes={node.children} />{/if}
|
|
219
|
+
</Override.component>
|
|
220
|
+
{#snippet failed()}{@render standard(node)}{/snippet}
|
|
221
|
+
</svelte:boundary>
|
|
222
|
+
{:else}
|
|
223
|
+
{@render standard(node)}
|
|
224
|
+
{/if}
|
|
225
|
+
{/snippet}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RenderInline } from '../../markdown/sanitize.js';
|
|
2
|
+
export type MarkdownInlinesProps = {
|
|
3
|
+
nodes: RenderInline[];
|
|
4
|
+
};
|
|
5
|
+
declare const MarkdownInlines: import("svelte").Component<MarkdownInlinesProps, {}, "">;
|
|
6
|
+
type MarkdownInlines = ReturnType<typeof MarkdownInlines>;
|
|
7
|
+
export default MarkdownInlines;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A link in Markdown, however it was written: `[text](address)`, a bare address, or an `<a>`
|
|
3
|
+
in raw HTML. A link to a heading of the same document goes there without changing the
|
|
4
|
+
page's address; any other click is offered to the app first.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts" module>
|
|
7
|
+
import * as stylex from '@stylexjs/stylex';
|
|
8
|
+
import type { Snippet } from 'svelte';
|
|
9
|
+
import { attrs, classes } from '../../internal/sx.js';
|
|
10
|
+
import { colors } from '../../tokens.stylex.js';
|
|
11
|
+
import Link from '../link/Link.svelte';
|
|
12
|
+
import { getMarkdownContext } from './context.js';
|
|
13
|
+
|
|
14
|
+
export type MarkdownLinkProps = {
|
|
15
|
+
href: string;
|
|
16
|
+
title?: string | null | undefined;
|
|
17
|
+
/** The link's words, as plain text. */
|
|
18
|
+
label: string;
|
|
19
|
+
children: Snippet;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const styles = stylex.create({
|
|
23
|
+
// The host a link really goes to, beside words that name another
|
|
24
|
+
host: { color: colors.textMuted, fontWeight: 'normal' }
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Words that read as an address: `https://a.example/x`, `www.a.example`, or `a.example/x`.
|
|
28
|
+
// A bare `README.md` is a file's name, not a host.
|
|
29
|
+
const reClaim = /^(?:(?:https?:\/\/|www\.)([^\s/?#:@]+)|((?:[a-z0-9-]+\.)+[a-z]{2,})\/)/i;
|
|
30
|
+
|
|
31
|
+
const bare = (host: string) => host.toLowerCase().replace(/^www\./, '');
|
|
32
|
+
|
|
33
|
+
/** The words under some nodes, as plain text: what a link reads as. */
|
|
34
|
+
export function wordsOf(nodes: ReadonlyArray<unknown>): string {
|
|
35
|
+
let out = '';
|
|
36
|
+
for (const node of nodes as ReadonlyArray<{ value?: unknown; children?: unknown }>) {
|
|
37
|
+
if (typeof node.value === 'string') out += node.value;
|
|
38
|
+
else if (Array.isArray(node.children)) out += wordsOf(node.children);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The host some words claim to lead to, or null when they do not read as an address. */
|
|
44
|
+
function claimedHost(text: string): string | null {
|
|
45
|
+
const m = reClaim.exec(text.trim());
|
|
46
|
+
return m ? bare(m[1] ?? m[2]!) : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A web address, read as the browser will, or null for an address that is not on the web. */
|
|
50
|
+
function webUrl(href: string): URL | null {
|
|
51
|
+
try {
|
|
52
|
+
const url = new URL(href, typeof location === 'undefined' ? undefined : location.href);
|
|
53
|
+
return url.protocol === 'http:' || url.protocol === 'https:' ? url : null;
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* What a link shows beside its words: where it really goes, whether its words name
|
|
61
|
+
* another site (the reader is then shown where it goes), and its tooltip, which is dropped
|
|
62
|
+
* when it would say the same false thing.
|
|
63
|
+
*/
|
|
64
|
+
export function describeLink(
|
|
65
|
+
href: string,
|
|
66
|
+
title: string | null | undefined,
|
|
67
|
+
label: string
|
|
68
|
+
): { host: string | null; elsewhere: boolean; title: string | undefined } {
|
|
69
|
+
const url = webUrl(href);
|
|
70
|
+
if (url === null) return { host: null, elsewhere: false, title: title ?? undefined };
|
|
71
|
+
const host = url.host;
|
|
72
|
+
// Names are compared without their ports: words seldom give one, and `localhost:3000`
|
|
73
|
+
// written as a link to itself names the same place
|
|
74
|
+
const real = bare(url.hostname);
|
|
75
|
+
const claimed = claimedHost(label);
|
|
76
|
+
const titled = title ? claimedHost(title) : null;
|
|
77
|
+
return {
|
|
78
|
+
host,
|
|
79
|
+
elsewhere: claimed !== null && claimed !== real,
|
|
80
|
+
title: titled !== null && titled !== real ? undefined : (title ?? undefined)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The class of the host shown beside a link's words. */
|
|
85
|
+
export const hostClass = classes(styles.host);
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<script lang="ts">
|
|
89
|
+
let { href, title = null, label, children }: MarkdownLinkProps = $props();
|
|
90
|
+
|
|
91
|
+
const md = getMarkdownContext();
|
|
92
|
+
|
|
93
|
+
const shown = $derived(describeLink(href, title, label));
|
|
94
|
+
|
|
95
|
+
function follow(event: MouseEvent) {
|
|
96
|
+
// A plain click on a link to a heading scrolls there; with a modifier key it is the
|
|
97
|
+
// browser's, to open in a new tab or window
|
|
98
|
+
const plain = !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey);
|
|
99
|
+
if (plain && href.startsWith('#') && md.goto(href.slice(1))) {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
md.links.open?.(href, event);
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<!-- A link to a heading of this document carries the heading's own id -->
|
|
108
|
+
<Link
|
|
109
|
+
href={(href.startsWith('#') && md.anchorHref(href.slice(1))) || href}
|
|
110
|
+
title={shown.title}
|
|
111
|
+
external={md.links.external(href)}
|
|
112
|
+
onclick={follow}
|
|
113
|
+
onauxclick={(event: MouseEvent) => md.links.open?.(href, event)}
|
|
114
|
+
>
|
|
115
|
+
{@render children()}{#if shown.elsewhere}<span
|
|
116
|
+
data-markdown-link-host
|
|
117
|
+
data-markdown-chrome
|
|
118
|
+
{...attrs([styles.host])}>{` (${shown.host})`}</span
|
|
119
|
+
>{/if}
|
|
120
|
+
</Link>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type MarkdownLinkProps = {
|
|
3
|
+
href: string;
|
|
4
|
+
title?: string | null | undefined;
|
|
5
|
+
/** The link's words, as plain text. */
|
|
6
|
+
label: string;
|
|
7
|
+
children: Snippet;
|
|
8
|
+
};
|
|
9
|
+
/** The words under some nodes, as plain text: what a link reads as. */
|
|
10
|
+
export declare function wordsOf(nodes: ReadonlyArray<unknown>): string;
|
|
11
|
+
/**
|
|
12
|
+
* What a link shows beside its words: where it really goes, whether its words name
|
|
13
|
+
* another site (the reader is then shown where it goes), and its tooltip, which is dropped
|
|
14
|
+
* when it would say the same false thing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function describeLink(href: string, title: string | null | undefined, label: string): {
|
|
17
|
+
host: string | null;
|
|
18
|
+
elsewhere: boolean;
|
|
19
|
+
title: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
/** The class of the host shown beside a link's words. */
|
|
22
|
+
export declare const hostClass: string;
|
|
23
|
+
declare const MarkdownLink: import("svelte").Component<MarkdownLinkProps, {}, "">;
|
|
24
|
+
type MarkdownLink = ReturnType<typeof MarkdownLink>;
|
|
25
|
+
export default MarkdownLink;
|