ai-design-system 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 +307 -0
- package/components/ai-elements/actions.tsx +65 -0
- package/components/ai-elements/artifact.tsx +147 -0
- package/components/ai-elements/branch.tsx +212 -0
- package/components/ai-elements/canvas.tsx +24 -0
- package/components/ai-elements/chain-of-thought.tsx +228 -0
- package/components/ai-elements/code-block.tsx +179 -0
- package/components/ai-elements/confirmation.tsx +169 -0
- package/components/ai-elements/connection.tsx +28 -0
- package/components/ai-elements/context.tsx +408 -0
- package/components/ai-elements/controls.tsx +18 -0
- package/components/ai-elements/conversation.tsx +97 -0
- package/components/ai-elements/edge.tsx +140 -0
- package/components/ai-elements/image.tsx +24 -0
- package/components/ai-elements/inline-citation.tsx +287 -0
- package/components/ai-elements/loader.tsx +96 -0
- package/components/ai-elements/message.tsx +80 -0
- package/components/ai-elements/node.tsx +71 -0
- package/components/ai-elements/open-in-chat.tsx +363 -0
- package/components/ai-elements/panel.tsx +15 -0
- package/components/ai-elements/plan.tsx +142 -0
- package/components/ai-elements/prompt-input.tsx +1352 -0
- package/components/ai-elements/queue.tsx +274 -0
- package/components/ai-elements/reasoning.tsx +178 -0
- package/components/ai-elements/response.tsx +22 -0
- package/components/ai-elements/shimmer.tsx +64 -0
- package/components/ai-elements/sources.tsx +77 -0
- package/components/ai-elements/suggestion.tsx +56 -0
- package/components/ai-elements/task.tsx +87 -0
- package/components/ai-elements/tool.tsx +179 -0
- package/components/ai-elements/toolbar.tsx +16 -0
- package/components/ai-elements/web-preview.tsx +263 -0
- package/components/blocks/AIConversation/AIConversation.stories.tsx +164 -0
- package/components/blocks/AIConversation/AIConversation.tsx +186 -0
- package/components/blocks/AIConversation/index.ts +8 -0
- package/components/blocks/AppSidebar/AppSidebar.stories.tsx +63 -0
- package/components/blocks/AppSidebar/AppSidebar.tsx +87 -0
- package/components/blocks/AppSidebar/index.ts +2 -0
- package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.stories.tsx +341 -0
- package/components/blocks/DocumentEditorWithComments/DocumentEditorWithComments.tsx +255 -0
- package/components/blocks/DocumentEditorWithComments/index.ts +9 -0
- package/components/blocks/FileChangeQueue/FileChangeQueue.stories.tsx +207 -0
- package/components/blocks/FileChangeQueue/FileChangeQueue.tsx +143 -0
- package/components/blocks/FileChangeQueue/index.ts +7 -0
- package/components/blocks/LayoutProvider/LayoutProvider.tsx +34 -0
- package/components/blocks/LayoutProvider/index.ts +1 -0
- package/components/blocks/index.ts +2 -0
- package/components/composites/AgentIndicator/AgentIndicator.stories.tsx +154 -0
- package/components/composites/AgentIndicator/AgentIndicator.tsx +102 -0
- package/components/composites/AgentIndicator/index.ts +8 -0
- package/components/composites/AppHeader/AppHeader.stories.tsx +46 -0
- package/components/composites/AppHeader/AppHeader.tsx +24 -0
- package/components/composites/AppHeader/index.ts +2 -0
- package/components/composites/CommentBox/CommentBox.stories.tsx +192 -0
- package/components/composites/CommentBox/CommentBox.tsx +364 -0
- package/components/composites/CommentBox/index.ts +8 -0
- package/components/composites/Confirmation/Confirmation.stories.tsx +151 -0
- package/components/composites/Confirmation/Confirmation.tsx +93 -0
- package/components/composites/Confirmation/index.ts +7 -0
- package/components/composites/DataTable/DataTable.stories.tsx +35 -0
- package/components/composites/DataTable/DataTable.tsx +95 -0
- package/components/composites/DataTable/index.ts +2 -0
- package/components/composites/DocumentEditor/DocumentEditor.css +106 -0
- package/components/composites/DocumentEditor/DocumentEditor.stories.tsx +927 -0
- package/components/composites/DocumentEditor/DocumentEditor.tsx +279 -0
- package/components/composites/DocumentEditor/index.ts +8 -0
- package/components/composites/FileQueue/FileQueue.stories.tsx +175 -0
- package/components/composites/FileQueue/FileQueue.tsx +161 -0
- package/components/composites/FileQueue/FileStatusBadge.tsx +74 -0
- package/components/composites/FileQueue/index.ts +24 -0
- package/components/composites/InteractiveChart/InteractiveChart.stories.tsx +49 -0
- package/components/composites/InteractiveChart/InteractiveChart.tsx +69 -0
- package/components/composites/InteractiveChart/index.ts +2 -0
- package/components/composites/ModeToggle/ModeToggle.stories.tsx +212 -0
- package/components/composites/ModeToggle/ModeToggle.tsx +100 -0
- package/components/composites/ModeToggle/index.ts +7 -0
- package/components/composites/NavUser/NavUser.stories.tsx +50 -0
- package/components/composites/NavUser/NavUser.tsx +60 -0
- package/components/composites/NavUser/index.ts +2 -0
- package/components/composites/NavigationList/NavigationList.stories.tsx +46 -0
- package/components/composites/NavigationList/NavigationList.tsx +46 -0
- package/components/composites/NavigationList/index.ts +2 -0
- package/components/composites/OrchestratorMessage/OrchestratorMessage.stories.tsx +188 -0
- package/components/composites/OrchestratorMessage/OrchestratorMessage.tsx +72 -0
- package/components/composites/OrchestratorMessage/index.ts +8 -0
- package/components/composites/PageContainer/PageContainer.stories.tsx +41 -0
- package/components/composites/PageContainer/PageContainer.tsx +24 -0
- package/components/composites/PageContainer/index.ts +2 -0
- package/components/composites/PromptInput/PromptInput.stories.tsx +200 -0
- package/components/composites/PromptInput/PromptInput.tsx +129 -0
- package/components/composites/PromptInput/index.ts +8 -0
- package/components/composites/SpecialistMessage/SpecialistMessage.stories.tsx +286 -0
- package/components/composites/SpecialistMessage/SpecialistMessage.tsx +107 -0
- package/components/composites/SpecialistMessage/index.ts +8 -0
- package/components/composites/StatsCard/StatsCard.stories.tsx +76 -0
- package/components/composites/StatsCard/StatsCard.tsx +81 -0
- package/components/composites/StatsCard/index.ts +2 -0
- package/components/composites/TablePagination/TablePagination.stories.tsx +38 -0
- package/components/composites/TablePagination/TablePagination.tsx +119 -0
- package/components/composites/TablePagination/index.ts +2 -0
- package/components/composites/TableToolbar/TableToolbar.stories.tsx +60 -0
- package/components/composites/TableToolbar/TableToolbar.tsx +66 -0
- package/components/composites/TableToolbar/index.ts +2 -0
- package/components/composites/ThemeSelector/ThemeSelector.stories.tsx +48 -0
- package/components/composites/ThemeSelector/ThemeSelector.tsx +79 -0
- package/components/composites/ThemeSelector/index.ts +2 -0
- package/components/composites/ToolCallDisplay/ToolCallDisplay.stories.tsx +49 -0
- package/components/composites/ToolCallDisplay/ToolCallDisplay.tsx +108 -0
- package/components/composites/ToolCallDisplay/index.ts +8 -0
- package/components/composites/UserMessage/UserMessage.stories.tsx +59 -0
- package/components/composites/UserMessage/UserMessage.tsx +52 -0
- package/components/composites/UserMessage/index.ts +8 -0
- package/components/composites/index.ts +90 -0
- package/components/features/AIDocEditor/AIDocEditor.behaviors.stories.tsx +451 -0
- package/components/features/AIDocEditor/AIDocEditor.mocks.ts +96 -0
- package/components/features/AIDocEditor/AIDocEditor.stories.tsx +140 -0
- package/components/features/AIDocEditor/AIDocEditor.tsx +130 -0
- package/components/features/AIDocEditor/index.ts +8 -0
- package/components/features/AIDocEditor/useAIDocEditor.d.ts +97 -0
- package/components/features/AIDocEditor/useAIDocEditor.mock.ts +83 -0
- package/components/features/PageLayout/PageLayout.behaviors.stories.tsx +119 -0
- package/components/features/PageLayout/PageLayout.mocks.ts +27 -0
- package/components/features/PageLayout/PageLayout.stories.tsx +142 -0
- package/components/features/PageLayout/PageLayout.tsx +94 -0
- package/components/features/PageLayout/index.ts +4 -0
- package/components/features/PageLayout/usePageLayout.d.ts +24 -0
- package/components/features/PageLayout/usePageLayout.mock.ts +19 -0
- package/components/features/RefinementPanel/README.md +189 -0
- package/components/features/RefinementPanel/RefinementPanel.behaviors.stories.tsx +475 -0
- package/components/features/RefinementPanel/RefinementPanel.mocks.ts +131 -0
- package/components/features/RefinementPanel/RefinementPanel.stories.tsx +141 -0
- package/components/features/RefinementPanel/RefinementPanel.tsx +160 -0
- package/components/features/RefinementPanel/index.ts +25 -0
- package/components/features/RefinementPanel/useRefinementPanel.d.ts +74 -0
- package/components/features/RefinementPanel/useRefinementPanel.mock.ts +121 -0
- package/components/features/SpecNavigator/SpecNavigator.behaviors.stories.tsx +379 -0
- package/components/features/SpecNavigator/SpecNavigator.mocks.ts +131 -0
- package/components/features/SpecNavigator/SpecNavigator.stories.tsx +122 -0
- package/components/features/SpecNavigator/SpecNavigator.tsx +43 -0
- package/components/features/SpecNavigator/index.ts +2 -0
- package/components/features/SpecNavigator/useSpecNavigator.d.ts +122 -0
- package/components/features/SpecNavigator/useSpecNavigator.mock.ts +93 -0
- package/components/features/index.ts +18 -0
- package/components/index.ts +14 -0
- package/components/primitives/Accordion/Accordion.stories.tsx +87 -0
- package/components/primitives/Accordion/Accordion.tsx +66 -0
- package/components/primitives/Accordion/index.ts +13 -0
- package/components/primitives/Alert/Alert.stories.tsx +422 -0
- package/components/primitives/Alert/Alert.tsx +61 -0
- package/components/primitives/Alert/index.ts +8 -0
- package/components/primitives/AlertDialog/AlertDialog.stories.tsx +367 -0
- package/components/primitives/AlertDialog/AlertDialog.tsx +182 -0
- package/components/primitives/AlertDialog/index.ts +25 -0
- package/components/primitives/Avatar/Avatar.stories.tsx +321 -0
- package/components/primitives/Avatar/Avatar.tsx +63 -0
- package/components/primitives/Avatar/index.ts +8 -0
- package/components/primitives/Badge/Badge.stories.tsx +74 -0
- package/components/primitives/Badge/Badge.tsx +49 -0
- package/components/primitives/Badge/index.ts +2 -0
- package/components/primitives/Button/Button.stories.tsx +445 -0
- package/components/primitives/Button/Button.tsx +89 -0
- package/components/primitives/Button/index.ts +7 -0
- package/components/primitives/Card/Card.stories.tsx +831 -0
- package/components/primitives/Card/Card.tsx +242 -0
- package/components/primitives/Card/index.ts +30 -0
- package/components/primitives/Carousel/Carousel.stories.tsx +32 -0
- package/components/primitives/Carousel/Carousel.tsx +63 -0
- package/components/primitives/Carousel/index.ts +13 -0
- package/components/primitives/Chart/Chart.stories.tsx +346 -0
- package/components/primitives/Chart/Chart.tsx +117 -0
- package/components/primitives/Chart/index.ts +20 -0
- package/components/primitives/Checkbox/Checkbox.stories.tsx +87 -0
- package/components/primitives/Checkbox/Checkbox.tsx +38 -0
- package/components/primitives/Checkbox/index.ts +2 -0
- package/components/primitives/Collapsible/Collapsible.stories.tsx +38 -0
- package/components/primitives/Collapsible/Collapsible.tsx +39 -0
- package/components/primitives/Collapsible/index.ts +8 -0
- package/components/primitives/Command/Command.stories.tsx +150 -0
- package/components/primitives/Command/Command.tsx +147 -0
- package/components/primitives/Command/index.ts +20 -0
- package/components/primitives/Dialog/Dialog.stories.tsx +390 -0
- package/components/primitives/Dialog/Dialog.tsx +140 -0
- package/components/primitives/Dialog/index.ts +22 -0
- package/components/primitives/Drawer/Drawer.stories.tsx +327 -0
- package/components/primitives/Drawer/Drawer.tsx +208 -0
- package/components/primitives/Drawer/index.ts +27 -0
- package/components/primitives/DropdownMenu/DropdownMenu.stories.tsx +150 -0
- package/components/primitives/DropdownMenu/DropdownMenu.tsx +73 -0
- package/components/primitives/DropdownMenu/index.ts +1 -0
- package/components/primitives/HoverCard/HoverCard.stories.tsx +26 -0
- package/components/primitives/HoverCard/HoverCard.tsx +39 -0
- package/components/primitives/HoverCard/index.ts +8 -0
- package/components/primitives/Icon/Icon.stories.tsx +281 -0
- package/components/primitives/Icon/Icon.tsx +87 -0
- package/components/primitives/Icon/index.ts +8 -0
- package/components/primitives/Input/Input.stories.tsx +370 -0
- package/components/primitives/Input/Input.tsx +88 -0
- package/components/primitives/Input/index.ts +7 -0
- package/components/primitives/InputGroup/InputGroup.stories.tsx +40 -0
- package/components/primitives/InputGroup/InputGroup.tsx +72 -0
- package/components/primitives/InputGroup/index.ts +14 -0
- package/components/primitives/Label/Label.stories.tsx +227 -0
- package/components/primitives/Label/Label.tsx +53 -0
- package/components/primitives/Label/index.ts +7 -0
- package/components/primitives/Popover/Popover.stories.tsx +42 -0
- package/components/primitives/Popover/Popover.tsx +107 -0
- package/components/primitives/Popover/index.ts +2 -0
- package/components/primitives/Progress/Progress.stories.tsx +340 -0
- package/components/primitives/Progress/Progress.tsx +31 -0
- package/components/primitives/Progress/index.ts +1 -0
- package/components/primitives/ScrollArea/ScrollArea.stories.tsx +26 -0
- package/components/primitives/ScrollArea/ScrollArea.tsx +28 -0
- package/components/primitives/ScrollArea/index.ts +6 -0
- package/components/primitives/Select/Select.stories.tsx +288 -0
- package/components/primitives/Select/Select.tsx +162 -0
- package/components/primitives/Select/index.ts +22 -0
- package/components/primitives/Separator/Separator.stories.tsx +264 -0
- package/components/primitives/Separator/Separator.tsx +48 -0
- package/components/primitives/Separator/index.ts +7 -0
- package/components/primitives/Sidebar/Sidebar.stories.tsx +358 -0
- package/components/primitives/Sidebar/Sidebar.tsx +317 -0
- package/components/primitives/Sidebar/index.ts +41 -0
- package/components/primitives/Table/Table.stories.tsx +389 -0
- package/components/primitives/Table/Table.tsx +191 -0
- package/components/primitives/Table/index.ts +26 -0
- package/components/primitives/Tabs/Tabs.stories.tsx +129 -0
- package/components/primitives/Tabs/Tabs.tsx +70 -0
- package/components/primitives/Tabs/index.ts +13 -0
- package/components/primitives/Textarea/Textarea.stories.tsx +358 -0
- package/components/primitives/Textarea/Textarea.tsx +91 -0
- package/components/primitives/Textarea/index.ts +7 -0
- package/components/primitives/ToggleGroup/ToggleGroup.stories.tsx +87 -0
- package/components/primitives/ToggleGroup/ToggleGroup.tsx +52 -0
- package/components/primitives/ToggleGroup/index.ts +6 -0
- package/components/primitives/Tooltip/Tooltip.stories.tsx +336 -0
- package/components/primitives/Tooltip/Tooltip.tsx +78 -0
- package/components/primitives/Tooltip/index.ts +10 -0
- package/components/primitives/index.ts +34 -0
- package/components/ui/accordion.tsx +66 -0
- package/components/ui/alert-dialog.tsx +157 -0
- package/components/ui/alert.tsx +66 -0
- package/components/ui/avatar.tsx +53 -0
- package/components/ui/badge.tsx +46 -0
- package/components/ui/button.tsx +60 -0
- package/components/ui/card.tsx +117 -0
- package/components/ui/carousel.tsx +241 -0
- package/components/ui/chart.tsx +334 -0
- package/components/ui/checkbox.tsx +32 -0
- package/components/ui/collapsible.tsx +33 -0
- package/components/ui/command.tsx +184 -0
- package/components/ui/dialog.tsx +143 -0
- package/components/ui/drawer.tsx +118 -0
- package/components/ui/dropdown-menu.tsx +257 -0
- package/components/ui/hover-card.tsx +44 -0
- package/components/ui/input-group.tsx +170 -0
- package/components/ui/input.tsx +48 -0
- package/components/ui/label.tsx +26 -0
- package/components/ui/popover.tsx +33 -0
- package/components/ui/progress.tsx +31 -0
- package/components/ui/scroll-area.tsx +58 -0
- package/components/ui/select.tsx +187 -0
- package/components/ui/separator.tsx +31 -0
- package/components/ui/sidebar.tsx +577 -0
- package/components/ui/table.tsx +120 -0
- package/components/ui/tabs.tsx +66 -0
- package/components/ui/textarea.tsx +46 -0
- package/components/ui/toggle-group.tsx +83 -0
- package/components/ui/toggle.tsx +47 -0
- package/components/ui/tooltip.tsx +61 -0
- package/dist/index.cjs +7389 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +75 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +7160 -0
- package/dist/index.js.map +1 -0
- package/hooks/useAIDocReviewer.d.ts +0 -0
- package/lib/utils.ts +6 -0
- package/package.json +140 -0
- package/tokens/color/base.json +14 -0
- package/tokens/color/dark.json +40 -0
- package/tokens/color/green.json +21 -0
- package/tokens/color/light.json +52 -0
- package/tokens/color/neutral.json +20 -0
- package/tokens/color/violet.json +21 -0
- package/tokens/spacing.json +22 -0
- package/utils/ai-editor/format-date.ts +41 -0
- package/utils/ai-editor/index.ts +22 -0
- package/utils/ai-editor/type-guards.ts +72 -0
- package/utils/ai-editor/validation.ts +130 -0
- package/utils/editor-annotations.ts +122 -0
|
@@ -0,0 +1,927 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocumentEditor Stories
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates the DocumentEditor component with various annotation types
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
8
|
+
import type { JSONContent } from '@tiptap/core'
|
|
9
|
+
import { DocumentEditor } from './DocumentEditor'
|
|
10
|
+
import type { DocumentEditorProps, Annotation } from '@/types/ai-editor'
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof DocumentEditor> = {
|
|
13
|
+
title: 'Composites/DocumentEditor',
|
|
14
|
+
component: DocumentEditor,
|
|
15
|
+
parameters: {
|
|
16
|
+
layout: 'padded',
|
|
17
|
+
},
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default meta
|
|
22
|
+
type Story = StoryObj<typeof DocumentEditor>
|
|
23
|
+
|
|
24
|
+
// Sample document content
|
|
25
|
+
const sampleContent: JSONContent = {
|
|
26
|
+
type: 'doc',
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'heading',
|
|
30
|
+
attrs: { level: 1 },
|
|
31
|
+
content: [{ type: 'text', text: 'Document Review Example' }],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'paragraph',
|
|
35
|
+
content: [
|
|
36
|
+
{ type: 'text', text: 'This is a sample document with various annotations. ' },
|
|
37
|
+
{ type: 'text', text: 'Some text has comments, ' },
|
|
38
|
+
{ type: 'text', text: 'some has suggestions, ' },
|
|
39
|
+
{ type: 'text', text: 'and some has block additions.' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'paragraph',
|
|
44
|
+
content: [
|
|
45
|
+
{ type: 'text', text: 'The editor supports inline annotations for comments and suggestions. ' },
|
|
46
|
+
{ type: 'text', text: 'Click on any highlighted text to see the annotation details.' },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Sample annotations
|
|
53
|
+
const commentAnnotations: Annotation[] = [
|
|
54
|
+
{
|
|
55
|
+
type: 'comment',
|
|
56
|
+
id: 'comment-1',
|
|
57
|
+
range: { from: 50, to: 70 },
|
|
58
|
+
createdAt: Date.now(),
|
|
59
|
+
userId: 'user-1',
|
|
60
|
+
data: {
|
|
61
|
+
thread: [
|
|
62
|
+
{
|
|
63
|
+
id: 'thread-1',
|
|
64
|
+
userId: 'user-1',
|
|
65
|
+
userName: 'John Doe',
|
|
66
|
+
contentRich: {
|
|
67
|
+
type: 'doc',
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: 'paragraph',
|
|
71
|
+
content: [{ type: 'text', text: 'This section needs clarification.' }],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
timestamp: Date.now(),
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
const suggestionAnnotations: Annotation[] = [
|
|
83
|
+
{
|
|
84
|
+
type: 'suggestion',
|
|
85
|
+
id: 'suggestion-1',
|
|
86
|
+
range: { from: 100, to: 120 },
|
|
87
|
+
createdAt: Date.now(),
|
|
88
|
+
userId: 'ai-1',
|
|
89
|
+
data: {
|
|
90
|
+
action: 'modify',
|
|
91
|
+
oldText: 'some has suggestions',
|
|
92
|
+
newText: 'others have AI suggestions',
|
|
93
|
+
reason: 'More descriptive wording',
|
|
94
|
+
thread: [],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: 'suggestion',
|
|
99
|
+
id: 'suggestion-2',
|
|
100
|
+
range: { from: 150, to: 170 },
|
|
101
|
+
createdAt: Date.now(),
|
|
102
|
+
userId: 'ai-1',
|
|
103
|
+
data: {
|
|
104
|
+
action: 'delete',
|
|
105
|
+
oldText: 'block additions',
|
|
106
|
+
reason: 'Redundant information',
|
|
107
|
+
thread: [],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
const blockAdditionAnnotations: Annotation[] = [
|
|
113
|
+
{
|
|
114
|
+
type: 'block-addition',
|
|
115
|
+
id: 'addition-1',
|
|
116
|
+
range: { from: 200, to: 200 },
|
|
117
|
+
createdAt: Date.now(),
|
|
118
|
+
userId: 'ai-1',
|
|
119
|
+
data: {
|
|
120
|
+
content: {
|
|
121
|
+
type: 'doc',
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: 'paragraph',
|
|
125
|
+
content: [
|
|
126
|
+
{
|
|
127
|
+
type: 'text',
|
|
128
|
+
text: 'This is a new paragraph suggested by AI to improve the document structure.',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
reason: 'Adding context for better understanding',
|
|
135
|
+
thread: [],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
const mixedAnnotations: Annotation[] = [
|
|
141
|
+
...commentAnnotations,
|
|
142
|
+
...suggestionAnnotations,
|
|
143
|
+
...blockAdditionAnnotations,
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Default story with no annotations
|
|
148
|
+
*/
|
|
149
|
+
export const Default: Story = {
|
|
150
|
+
args: {
|
|
151
|
+
content: sampleContent,
|
|
152
|
+
format: 'json', // Explicit JSON format (default)
|
|
153
|
+
annotations: [],
|
|
154
|
+
readOnly: true,
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Story with comment highlights
|
|
160
|
+
*/
|
|
161
|
+
export const WithComments: Story = {
|
|
162
|
+
args: {
|
|
163
|
+
content: sampleContent,
|
|
164
|
+
annotations: commentAnnotations,
|
|
165
|
+
readOnly: true,
|
|
166
|
+
onAnnotationClick: (id) => console.log('Clicked annotation:', id),
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Story with suggestion highlights
|
|
172
|
+
*/
|
|
173
|
+
export const WithSuggestions: Story = {
|
|
174
|
+
args: {
|
|
175
|
+
content: sampleContent,
|
|
176
|
+
annotations: suggestionAnnotations,
|
|
177
|
+
readOnly: true,
|
|
178
|
+
onAnnotationClick: (id) => console.log('Clicked annotation:', id),
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Story with block additions
|
|
184
|
+
*/
|
|
185
|
+
export const WithBlockAdditions: Story = {
|
|
186
|
+
args: {
|
|
187
|
+
content: sampleContent,
|
|
188
|
+
annotations: blockAdditionAnnotations,
|
|
189
|
+
readOnly: true,
|
|
190
|
+
onAnnotationClick: (id) => console.log('Clicked annotation:', id),
|
|
191
|
+
},
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Story with multiple annotation types
|
|
196
|
+
*/
|
|
197
|
+
export const WithMultipleAnnotations: Story = {
|
|
198
|
+
args: {
|
|
199
|
+
content: sampleContent,
|
|
200
|
+
annotations: mixedAnnotations,
|
|
201
|
+
readOnly: true,
|
|
202
|
+
onAnnotationClick: (id) => console.log('Clicked annotation:', id),
|
|
203
|
+
onAnnotationHover: (id) => console.log('Hovered annotation:', id),
|
|
204
|
+
onTextSelect: (range, text) => console.log('Selected text:', text, 'at range:', range),
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Story with selected annotation (active state)
|
|
210
|
+
*/
|
|
211
|
+
export const WithSelectedAnnotation: Story = {
|
|
212
|
+
args: {
|
|
213
|
+
content: sampleContent,
|
|
214
|
+
annotations: mixedAnnotations,
|
|
215
|
+
selectedAnnotationId: 'comment-1',
|
|
216
|
+
readOnly: true,
|
|
217
|
+
onAnnotationClick: (id) => console.log('Clicked annotation:', id),
|
|
218
|
+
},
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Story in editable mode (not read-only)
|
|
223
|
+
*/
|
|
224
|
+
export const EditableMode: Story = {
|
|
225
|
+
args: {
|
|
226
|
+
content: sampleContent,
|
|
227
|
+
annotations: commentAnnotations,
|
|
228
|
+
readOnly: false,
|
|
229
|
+
onTextSelect: (range, text) => console.log('Selected text:', text, 'at range:', range),
|
|
230
|
+
},
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Rich Text Showcase - Demonstrates all supported rich text formatting
|
|
235
|
+
*
|
|
236
|
+
* This story showcases all Tiptap StarterKit features supported by DocumentEditor:
|
|
237
|
+
* - Text formatting: Bold, Italic, Strike, Code
|
|
238
|
+
* - Headings: H1, H2, H3, H4, H5, H6
|
|
239
|
+
* - Lists: Bullet lists, Ordered lists
|
|
240
|
+
* - Blocks: Blockquote, Code block, Horizontal rule
|
|
241
|
+
* - Paragraph: Regular paragraphs with hard breaks
|
|
242
|
+
*
|
|
243
|
+
* Note: DocumentEditor uses Tiptap in headless mode (EditorContent only)
|
|
244
|
+
* All formatting is rendered via Tiptap's JSONContent structure
|
|
245
|
+
*/
|
|
246
|
+
export const RichTextShowcase: Story = {
|
|
247
|
+
args: {
|
|
248
|
+
content: {
|
|
249
|
+
type: 'doc',
|
|
250
|
+
content: [
|
|
251
|
+
// Title
|
|
252
|
+
{
|
|
253
|
+
type: 'heading',
|
|
254
|
+
attrs: { level: 1 },
|
|
255
|
+
content: [{ type: 'text', text: 'Welcome to DocumentEditor ✨' }],
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
// Intro callout
|
|
259
|
+
{
|
|
260
|
+
type: 'blockquote',
|
|
261
|
+
content: [
|
|
262
|
+
{
|
|
263
|
+
type: 'paragraph',
|
|
264
|
+
content: [
|
|
265
|
+
{ type: 'text', text: '📘 Did you know?', marks: [{ type: 'bold' }] },
|
|
266
|
+
{ type: 'hardBreak' },
|
|
267
|
+
{ type: 'text', text: 'This editor is powered by open-source Tiptap in headless mode. All rich text features are rendered using Tiptap StarterKit extensions with custom annotation support.' },
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
// Section: Headings
|
|
274
|
+
{
|
|
275
|
+
type: 'heading',
|
|
276
|
+
attrs: { level: 2 },
|
|
277
|
+
content: [{ type: 'text', text: 'Headings' }],
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
type: 'paragraph',
|
|
281
|
+
content: [{ type: 'text', text: 'Six levels of headings are supported:' }],
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
type: 'heading',
|
|
285
|
+
attrs: { level: 1 },
|
|
286
|
+
content: [{ type: 'text', text: 'Heading 1 - Main Title' }],
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: 'heading',
|
|
290
|
+
attrs: { level: 2 },
|
|
291
|
+
content: [{ type: 'text', text: 'Heading 2 - Section Title' }],
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
type: 'heading',
|
|
295
|
+
attrs: { level: 3 },
|
|
296
|
+
content: [{ type: 'text', text: 'Heading 3 - Subsection' }],
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
type: 'heading',
|
|
300
|
+
attrs: { level: 4 },
|
|
301
|
+
content: [{ type: 'text', text: 'Heading 4 - Minor Heading' }],
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
type: 'heading',
|
|
305
|
+
attrs: { level: 5 },
|
|
306
|
+
content: [{ type: 'text', text: 'Heading 5 - Small Heading' }],
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
type: 'heading',
|
|
310
|
+
attrs: { level: 6 },
|
|
311
|
+
content: [{ type: 'text', text: 'Heading 6 - Smallest Heading' }],
|
|
312
|
+
},
|
|
313
|
+
|
|
314
|
+
// Horizontal rule
|
|
315
|
+
{ type: 'horizontalRule' },
|
|
316
|
+
|
|
317
|
+
// Section: Text Formatting
|
|
318
|
+
{
|
|
319
|
+
type: 'heading',
|
|
320
|
+
attrs: { level: 2 },
|
|
321
|
+
content: [{ type: 'text', text: 'Text Formatting' }],
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
type: 'paragraph',
|
|
325
|
+
content: [{ type: 'text', text: 'Try some formatting:' }],
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
type: 'bulletList',
|
|
329
|
+
content: [
|
|
330
|
+
{
|
|
331
|
+
type: 'listItem',
|
|
332
|
+
content: [
|
|
333
|
+
{
|
|
334
|
+
type: 'paragraph',
|
|
335
|
+
content: [
|
|
336
|
+
{ type: 'text', text: 'Make text ' },
|
|
337
|
+
{ type: 'text', text: 'bold', marks: [{ type: 'bold' }] },
|
|
338
|
+
{ type: 'text', text: ' to emphasize' },
|
|
339
|
+
],
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
type: 'listItem',
|
|
345
|
+
content: [
|
|
346
|
+
{
|
|
347
|
+
type: 'paragraph',
|
|
348
|
+
content: [
|
|
349
|
+
{ type: 'text', text: 'Use ' },
|
|
350
|
+
{ type: 'text', text: 'italic', marks: [{ type: 'italic' }] },
|
|
351
|
+
{ type: 'text', text: ' for subtle emphasis' },
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
type: 'listItem',
|
|
358
|
+
content: [
|
|
359
|
+
{
|
|
360
|
+
type: 'paragraph',
|
|
361
|
+
content: [
|
|
362
|
+
{ type: 'text', text: 'Add ' },
|
|
363
|
+
{ type: 'text', text: 'strikethrough', marks: [{ type: 'strike' }] },
|
|
364
|
+
{ type: 'text', text: ' for deletions' },
|
|
365
|
+
],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
type: 'listItem',
|
|
371
|
+
content: [
|
|
372
|
+
{
|
|
373
|
+
type: 'paragraph',
|
|
374
|
+
content: [
|
|
375
|
+
{ type: 'text', text: 'Highlight ' },
|
|
376
|
+
{ type: 'text', text: 'inline code', marks: [{ type: 'code' }] },
|
|
377
|
+
{ type: 'text', text: ' snippets' },
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
type: 'listItem',
|
|
384
|
+
content: [
|
|
385
|
+
{
|
|
386
|
+
type: 'paragraph',
|
|
387
|
+
content: [
|
|
388
|
+
{ type: 'text', text: 'Use ' },
|
|
389
|
+
{ type: 'text', text: 'highlight', marks: [{ type: 'highlight' }] },
|
|
390
|
+
{ type: 'text', text: ' to draw attention' },
|
|
391
|
+
],
|
|
392
|
+
},
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
type: 'listItem',
|
|
397
|
+
content: [
|
|
398
|
+
{
|
|
399
|
+
type: 'paragraph',
|
|
400
|
+
content: [
|
|
401
|
+
{ type: 'text', text: 'Add ' },
|
|
402
|
+
{
|
|
403
|
+
type: 'text',
|
|
404
|
+
text: 'links',
|
|
405
|
+
marks: [{ type: 'link', attrs: { href: 'https://tiptap.dev' } }]
|
|
406
|
+
},
|
|
407
|
+
{ type: 'text', text: ' to external resources' },
|
|
408
|
+
],
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
// Combined formatting example
|
|
416
|
+
{
|
|
417
|
+
type: 'paragraph',
|
|
418
|
+
content: [
|
|
419
|
+
{ type: 'text', text: 'You can also combine formats like ' },
|
|
420
|
+
{
|
|
421
|
+
type: 'text',
|
|
422
|
+
text: 'bold italic',
|
|
423
|
+
marks: [{ type: 'bold' }, { type: 'italic' }]
|
|
424
|
+
},
|
|
425
|
+
{ type: 'text', text: ' or ' },
|
|
426
|
+
{
|
|
427
|
+
type: 'text',
|
|
428
|
+
text: 'bold strikethrough',
|
|
429
|
+
marks: [{ type: 'bold' }, { type: 'strike' }]
|
|
430
|
+
},
|
|
431
|
+
{ type: 'text', text: '.' },
|
|
432
|
+
],
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
{ type: 'horizontalRule' },
|
|
436
|
+
|
|
437
|
+
// Section: Lists
|
|
438
|
+
{
|
|
439
|
+
type: 'heading',
|
|
440
|
+
attrs: { level: 2 },
|
|
441
|
+
content: [{ type: 'text', text: 'Lists' }],
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
// Bullet list
|
|
445
|
+
{
|
|
446
|
+
type: 'paragraph',
|
|
447
|
+
content: [{ type: 'text', text: 'Bullet lists for unordered items:' }],
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
type: 'bulletList',
|
|
451
|
+
content: [
|
|
452
|
+
{
|
|
453
|
+
type: 'listItem',
|
|
454
|
+
content: [
|
|
455
|
+
{
|
|
456
|
+
type: 'paragraph',
|
|
457
|
+
content: [{ type: 'text', text: 'First bullet point' }],
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
type: 'listItem',
|
|
463
|
+
content: [
|
|
464
|
+
{
|
|
465
|
+
type: 'paragraph',
|
|
466
|
+
content: [{ type: 'text', text: 'Second bullet point with ' }, { type: 'text', text: 'bold text', marks: [{ type: 'bold' }] }],
|
|
467
|
+
},
|
|
468
|
+
],
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
type: 'listItem',
|
|
472
|
+
content: [
|
|
473
|
+
{
|
|
474
|
+
type: 'paragraph',
|
|
475
|
+
content: [{ type: 'text', text: 'Third bullet point with nested items:' }],
|
|
476
|
+
},
|
|
477
|
+
// Nested list
|
|
478
|
+
{
|
|
479
|
+
type: 'bulletList',
|
|
480
|
+
content: [
|
|
481
|
+
{
|
|
482
|
+
type: 'listItem',
|
|
483
|
+
content: [
|
|
484
|
+
{
|
|
485
|
+
type: 'paragraph',
|
|
486
|
+
content: [{ type: 'text', text: 'Nested bullet point' }],
|
|
487
|
+
},
|
|
488
|
+
],
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
type: 'listItem',
|
|
492
|
+
content: [
|
|
493
|
+
{
|
|
494
|
+
type: 'paragraph',
|
|
495
|
+
content: [{ type: 'text', text: 'Another nested point' }],
|
|
496
|
+
},
|
|
497
|
+
],
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
},
|
|
501
|
+
],
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
// Ordered list
|
|
507
|
+
{
|
|
508
|
+
type: 'paragraph',
|
|
509
|
+
content: [{ type: 'text', text: 'Numbered lists for ordered items:' }],
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
type: 'orderedList',
|
|
513
|
+
content: [
|
|
514
|
+
{
|
|
515
|
+
type: 'listItem',
|
|
516
|
+
content: [
|
|
517
|
+
{
|
|
518
|
+
type: 'paragraph',
|
|
519
|
+
content: [{ type: 'text', text: 'First numbered item' }],
|
|
520
|
+
},
|
|
521
|
+
],
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
type: 'listItem',
|
|
525
|
+
content: [
|
|
526
|
+
{
|
|
527
|
+
type: 'paragraph',
|
|
528
|
+
content: [{ type: 'text', text: 'Second numbered item' }],
|
|
529
|
+
},
|
|
530
|
+
],
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
type: 'listItem',
|
|
534
|
+
content: [
|
|
535
|
+
{
|
|
536
|
+
type: 'paragraph',
|
|
537
|
+
content: [{ type: 'text', text: 'Third numbered item' }],
|
|
538
|
+
},
|
|
539
|
+
],
|
|
540
|
+
},
|
|
541
|
+
],
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
{ type: 'horizontalRule' },
|
|
545
|
+
|
|
546
|
+
// Section: Code
|
|
547
|
+
{
|
|
548
|
+
type: 'heading',
|
|
549
|
+
attrs: { level: 2 },
|
|
550
|
+
content: [{ type: 'text', text: 'Code' }],
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
type: 'paragraph',
|
|
554
|
+
content: [
|
|
555
|
+
{ type: 'text', text: 'Use ' },
|
|
556
|
+
{ type: 'text', text: 'inline code', marks: [{ type: 'code' }] },
|
|
557
|
+
{ type: 'text', text: ' for short snippets or commands like ' },
|
|
558
|
+
{ type: 'text', text: 'npm install', marks: [{ type: 'code' }] },
|
|
559
|
+
{ type: 'text', text: '.' },
|
|
560
|
+
],
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
type: 'paragraph',
|
|
564
|
+
content: [{ type: 'text', text: 'For longer code, use code blocks:' }],
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
type: 'codeBlock',
|
|
568
|
+
content: [
|
|
569
|
+
{
|
|
570
|
+
type: 'text',
|
|
571
|
+
text: 'function example() {\n const message = "This is a code block";\n return message;\n}',
|
|
572
|
+
},
|
|
573
|
+
],
|
|
574
|
+
},
|
|
575
|
+
|
|
576
|
+
{ type: 'horizontalRule' },
|
|
577
|
+
|
|
578
|
+
// Section: Quotes
|
|
579
|
+
{
|
|
580
|
+
type: 'heading',
|
|
581
|
+
attrs: { level: 2 },
|
|
582
|
+
content: [{ type: 'text', text: 'Blockquotes' }],
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
type: 'paragraph',
|
|
586
|
+
content: [{ type: 'text', text: 'Use blockquotes for callouts or quotations:' }],
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
type: 'blockquote',
|
|
590
|
+
content: [
|
|
591
|
+
{
|
|
592
|
+
type: 'paragraph',
|
|
593
|
+
content: [
|
|
594
|
+
{ type: 'text', text: '💡 Pro tip:', marks: [{ type: 'bold' }] },
|
|
595
|
+
{ type: 'hardBreak' },
|
|
596
|
+
{ type: 'text', text: 'Blockquotes can contain ' },
|
|
597
|
+
{ type: 'text', text: 'formatted text', marks: [{ type: 'italic' }] },
|
|
598
|
+
{ type: 'text', text: ' and are great for highlighting important information or quotes.' },
|
|
599
|
+
],
|
|
600
|
+
},
|
|
601
|
+
],
|
|
602
|
+
},
|
|
603
|
+
|
|
604
|
+
{ type: 'horizontalRule' },
|
|
605
|
+
|
|
606
|
+
// Section: Summary
|
|
607
|
+
{
|
|
608
|
+
type: 'heading',
|
|
609
|
+
attrs: { level: 2 },
|
|
610
|
+
content: [{ type: 'text', text: 'Summary' }],
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
type: 'paragraph',
|
|
614
|
+
content: [
|
|
615
|
+
{ type: 'text', text: 'All the formatting above is rendered using ' },
|
|
616
|
+
{ type: 'text', text: 'Tiptap StarterKit', marks: [{ type: 'bold' }] },
|
|
617
|
+
{ type: 'text', text: ' extensions in ' },
|
|
618
|
+
{ type: 'text', text: 'headless mode', marks: [{ type: 'code' }] },
|
|
619
|
+
{ type: 'text', text: '. The DocumentEditor component provides a clean, read-only view perfect for document review and annotation.' },
|
|
620
|
+
],
|
|
621
|
+
},
|
|
622
|
+
],
|
|
623
|
+
},
|
|
624
|
+
annotations: [],
|
|
625
|
+
readOnly: true,
|
|
626
|
+
},
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Diff Display - Shows text modifications with insertions, deletions, and modifications
|
|
631
|
+
* This story demonstrates the diff display capabilities similar to DiffDisplay block
|
|
632
|
+
*/
|
|
633
|
+
export const DiffDisplay: Story = {
|
|
634
|
+
args: {
|
|
635
|
+
content: {
|
|
636
|
+
type: 'doc',
|
|
637
|
+
content: [
|
|
638
|
+
{
|
|
639
|
+
type: 'heading',
|
|
640
|
+
attrs: { level: 2 },
|
|
641
|
+
content: [{ type: 'text', text: 'Text Modification Examples' }],
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
type: 'paragraph',
|
|
645
|
+
content: [
|
|
646
|
+
{ type: 'text', text: 'This paragraph shows a ' },
|
|
647
|
+
{ type: 'text', text: 'deletion example' },
|
|
648
|
+
{ type: 'text', text: ' with strikethrough text.' },
|
|
649
|
+
],
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
type: 'paragraph',
|
|
653
|
+
content: [
|
|
654
|
+
{ type: 'text', text: 'This paragraph shows an ' },
|
|
655
|
+
{ type: 'text', text: 'insertion example' },
|
|
656
|
+
{ type: 'text', text: ' with green highlighted text.' },
|
|
657
|
+
],
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
type: 'paragraph',
|
|
661
|
+
content: [
|
|
662
|
+
{ type: 'text', text: 'This paragraph shows a ' },
|
|
663
|
+
{ type: 'text', text: 'modification example' },
|
|
664
|
+
{ type: 'text', text: ' where text is replaced.' },
|
|
665
|
+
],
|
|
666
|
+
},
|
|
667
|
+
],
|
|
668
|
+
},
|
|
669
|
+
annotations: [
|
|
670
|
+
{
|
|
671
|
+
type: 'suggestion',
|
|
672
|
+
id: 'diff-delete',
|
|
673
|
+
range: { from: 60, to: 76 }, // "deletion example"
|
|
674
|
+
createdAt: Date.now(),
|
|
675
|
+
userId: 'ai-1',
|
|
676
|
+
data: {
|
|
677
|
+
action: 'delete',
|
|
678
|
+
oldText: 'deletion example',
|
|
679
|
+
reason: 'Remove redundant text',
|
|
680
|
+
thread: [],
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
type: 'suggestion',
|
|
685
|
+
id: 'diff-insert',
|
|
686
|
+
range: { from: 125, to: 142 }, // "insertion example"
|
|
687
|
+
createdAt: Date.now(),
|
|
688
|
+
userId: 'ai-1',
|
|
689
|
+
data: {
|
|
690
|
+
action: 'insert',
|
|
691
|
+
newText: 'insertion example',
|
|
692
|
+
reason: 'Add clarifying text',
|
|
693
|
+
thread: [],
|
|
694
|
+
},
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
type: 'suggestion',
|
|
698
|
+
id: 'diff-modify',
|
|
699
|
+
range: { from: 192, to: 212 }, // "modification example"
|
|
700
|
+
createdAt: Date.now(),
|
|
701
|
+
userId: 'ai-1',
|
|
702
|
+
data: {
|
|
703
|
+
action: 'modify',
|
|
704
|
+
oldText: 'modification example',
|
|
705
|
+
newText: 'replacement example',
|
|
706
|
+
reason: 'More precise wording',
|
|
707
|
+
thread: [],
|
|
708
|
+
},
|
|
709
|
+
},
|
|
710
|
+
],
|
|
711
|
+
readOnly: true,
|
|
712
|
+
onAnnotationClick: (id) => console.log('Clicked diff annotation:', id),
|
|
713
|
+
},
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Markdown String Input - Demonstrates passing markdown strings directly
|
|
718
|
+
*
|
|
719
|
+
* This story shows how to use the DocumentEditor with markdown format.
|
|
720
|
+
* When format="markdown", you can pass plain markdown strings (like LLM responses)
|
|
721
|
+
* without manual JSON conversion. The Tiptap Markdown extension automatically parses
|
|
722
|
+
* and renders the markdown.
|
|
723
|
+
*
|
|
724
|
+
* Perfect for: LLM-generated content, markdown files, user input
|
|
725
|
+
*/
|
|
726
|
+
export const MarkdownStringInput: Story = {
|
|
727
|
+
args: {
|
|
728
|
+
content: `# Markdown String Input Demo
|
|
729
|
+
|
|
730
|
+
This content is passed as a **plain markdown string** - no JSON conversion needed!
|
|
731
|
+
|
|
732
|
+
## Why Use Markdown Format?
|
|
733
|
+
|
|
734
|
+
When working with LLMs or markdown content, you can pass strings directly:
|
|
735
|
+
|
|
736
|
+
- ✅ **No manual parsing** - Just pass the string
|
|
737
|
+
- ✅ **LLM-friendly** - Most LLMs output markdown
|
|
738
|
+
- ✅ **Simple API** - Set \`format="markdown"\` and you're done
|
|
739
|
+
|
|
740
|
+
## Supported Markdown Features
|
|
741
|
+
|
|
742
|
+
### Text Formatting
|
|
743
|
+
|
|
744
|
+
Make text **bold**, *italic*, or ~~strikethrough~~. Use \`inline code\` for technical terms.
|
|
745
|
+
|
|
746
|
+
### Lists
|
|
747
|
+
|
|
748
|
+
Unordered lists:
|
|
749
|
+
- First item
|
|
750
|
+
- Second item
|
|
751
|
+
- Nested item
|
|
752
|
+
- Another nested item
|
|
753
|
+
- Third item
|
|
754
|
+
|
|
755
|
+
Ordered lists:
|
|
756
|
+
1. Step one
|
|
757
|
+
2. Step two
|
|
758
|
+
3. Step three
|
|
759
|
+
|
|
760
|
+
### Code Blocks
|
|
761
|
+
|
|
762
|
+
\`\`\`javascript
|
|
763
|
+
function greet(name) {
|
|
764
|
+
return \`Hello, \${name}!\`;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
console.log(greet("World"));
|
|
768
|
+
\`\`\`
|
|
769
|
+
|
|
770
|
+
### Blockquotes
|
|
771
|
+
|
|
772
|
+
> This is a blockquote.
|
|
773
|
+
> It can span multiple lines and contain **formatted text**.
|
|
774
|
+
|
|
775
|
+
### Headings
|
|
776
|
+
|
|
777
|
+
# H1 - Main Title
|
|
778
|
+
## H2 - Section
|
|
779
|
+
### H3 - Subsection
|
|
780
|
+
#### H4 - Minor Heading
|
|
781
|
+
##### H5 - Small Heading
|
|
782
|
+
###### H6 - Smallest Heading
|
|
783
|
+
|
|
784
|
+
---
|
|
785
|
+
|
|
786
|
+
## Example: LLM Response
|
|
787
|
+
|
|
788
|
+
Imagine an LLM returns this markdown string:
|
|
789
|
+
|
|
790
|
+
\`\`\`markdown
|
|
791
|
+
## Analysis Results
|
|
792
|
+
|
|
793
|
+
The code review identified **3 issues**:
|
|
794
|
+
|
|
795
|
+
1. Missing error handling in \`fetchData()\`
|
|
796
|
+
2. Unused variable \`tempResult\`
|
|
797
|
+
3. Consider using \`async/await\` instead of promises
|
|
798
|
+
|
|
799
|
+
*Recommendation:* Refactor the data fetching logic.
|
|
800
|
+
\`\`\`
|
|
801
|
+
|
|
802
|
+
You can pass it directly to DocumentEditor without any parsing!
|
|
803
|
+
|
|
804
|
+
---
|
|
805
|
+
|
|
806
|
+
**Note:** This entire story content is a single markdown string passed to the \`content\` prop.`,
|
|
807
|
+
format: 'markdown',
|
|
808
|
+
annotations: [],
|
|
809
|
+
readOnly: true,
|
|
810
|
+
},
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Markdown With Annotations - Shows markdown format working with comments, suggestions, and diffs
|
|
815
|
+
*
|
|
816
|
+
* This story demonstrates that markdown format works seamlessly with all annotation features:
|
|
817
|
+
* - Comments on markdown text
|
|
818
|
+
* - Suggestions (insert, delete, modify)
|
|
819
|
+
* - Block additions
|
|
820
|
+
*
|
|
821
|
+
* The annotations use character positions that work with the parsed markdown content.
|
|
822
|
+
*/
|
|
823
|
+
export const MarkdownWithAnnotations: Story = {
|
|
824
|
+
args: {
|
|
825
|
+
content: `# Document Review with Markdown
|
|
826
|
+
|
|
827
|
+
This document demonstrates how **markdown format** works with annotations.
|
|
828
|
+
|
|
829
|
+
## Section with Comments
|
|
830
|
+
|
|
831
|
+
This paragraph has a comment annotation. You can click on the highlighted text to see the comment thread.
|
|
832
|
+
|
|
833
|
+
## Section with Suggestions
|
|
834
|
+
|
|
835
|
+
The AI suggests some improvements to this text. You'll see deletions in red and insertions in green.
|
|
836
|
+
|
|
837
|
+
## Code Example
|
|
838
|
+
|
|
839
|
+
\`\`\`javascript
|
|
840
|
+
function calculateTotal(items) {
|
|
841
|
+
return items.reduce((sum, item) => sum + item.price, 0);
|
|
842
|
+
}
|
|
843
|
+
\`\`\`
|
|
844
|
+
|
|
845
|
+
The code above can be optimized for better performance.
|
|
846
|
+
|
|
847
|
+
---
|
|
848
|
+
|
|
849
|
+
**Markdown + Annotations = Perfect for AI Document Review!**`,
|
|
850
|
+
format: 'markdown',
|
|
851
|
+
annotations: [
|
|
852
|
+
// Comment annotation
|
|
853
|
+
{
|
|
854
|
+
type: 'comment',
|
|
855
|
+
id: 'md-comment-1',
|
|
856
|
+
range: { from: 120, to: 160 },
|
|
857
|
+
createdAt: Date.now(),
|
|
858
|
+
userId: 'user-1',
|
|
859
|
+
data: {
|
|
860
|
+
thread: [
|
|
861
|
+
{
|
|
862
|
+
id: 'thread-1',
|
|
863
|
+
userId: 'user-1',
|
|
864
|
+
userName: 'John Doe',
|
|
865
|
+
contentRich: {
|
|
866
|
+
type: 'doc',
|
|
867
|
+
content: [
|
|
868
|
+
{
|
|
869
|
+
type: 'paragraph',
|
|
870
|
+
content: [{ type: 'text', text: 'This is great! Markdown format makes it so easy to work with LLM outputs.' }],
|
|
871
|
+
},
|
|
872
|
+
],
|
|
873
|
+
},
|
|
874
|
+
timestamp: Date.now(),
|
|
875
|
+
},
|
|
876
|
+
],
|
|
877
|
+
},
|
|
878
|
+
},
|
|
879
|
+
// Suggestion - delete
|
|
880
|
+
{
|
|
881
|
+
type: 'suggestion',
|
|
882
|
+
id: 'md-suggestion-1',
|
|
883
|
+
range: { from: 250, to: 270 },
|
|
884
|
+
createdAt: Date.now(),
|
|
885
|
+
userId: 'ai-1',
|
|
886
|
+
data: {
|
|
887
|
+
action: 'delete',
|
|
888
|
+
oldText: 'some improvements to',
|
|
889
|
+
reason: 'More concise wording',
|
|
890
|
+
thread: [],
|
|
891
|
+
},
|
|
892
|
+
},
|
|
893
|
+
// Suggestion - insert
|
|
894
|
+
{
|
|
895
|
+
type: 'suggestion',
|
|
896
|
+
id: 'md-suggestion-2',
|
|
897
|
+
range: { from: 271, to: 271 },
|
|
898
|
+
createdAt: Date.now(),
|
|
899
|
+
userId: 'ai-1',
|
|
900
|
+
data: {
|
|
901
|
+
action: 'insert',
|
|
902
|
+
newText: 'better ',
|
|
903
|
+
reason: 'Clearer language',
|
|
904
|
+
thread: [],
|
|
905
|
+
},
|
|
906
|
+
},
|
|
907
|
+
// Suggestion - modify
|
|
908
|
+
{
|
|
909
|
+
type: 'suggestion',
|
|
910
|
+
id: 'md-suggestion-3',
|
|
911
|
+
range: { from: 400, to: 420 },
|
|
912
|
+
createdAt: Date.now(),
|
|
913
|
+
userId: 'ai-1',
|
|
914
|
+
data: {
|
|
915
|
+
action: 'modify',
|
|
916
|
+
oldText: 'can be optimized',
|
|
917
|
+
newText: 'could use memoization',
|
|
918
|
+
reason: 'More specific suggestion',
|
|
919
|
+
thread: [],
|
|
920
|
+
},
|
|
921
|
+
},
|
|
922
|
+
],
|
|
923
|
+
readOnly: true,
|
|
924
|
+
onAnnotationClick: (id) => console.log('Clicked annotation:', id),
|
|
925
|
+
onAnnotationHover: (id) => console.log('Hovered annotation:', id),
|
|
926
|
+
},
|
|
927
|
+
}
|