@docyrus/ui-pro-ai-assistant 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26161 -0
- package/dist/index.js.map +1 -0
- package/package.json +155 -0
- package/src/components/assistant-animations.tsx +29 -0
- package/src/components/assistant-dialogs.tsx +235 -0
- package/src/components/code-view.tsx +278 -0
- package/src/components/create-agent-task.tsx +104 -0
- package/src/components/create-new-work-version.tsx +30 -0
- package/src/components/extract-web.tsx +160 -0
- package/src/components/forward-to-agent.tsx +90 -0
- package/src/components/generate-chart.tsx +101 -0
- package/src/components/generative-action-button.tsx +122 -0
- package/src/components/generative-tool.tsx +685 -0
- package/src/components/generative-ui-object.tsx +210 -0
- package/src/components/input-area.tsx +1209 -0
- package/src/components/json-schema-layout.tsx +326 -0
- package/src/components/list-item-card.tsx +92 -0
- package/src/components/mermaid-diagram.tsx +192 -0
- package/src/components/preview-image.tsx +47 -0
- package/src/components/request-approval.tsx +48 -0
- package/src/components/request-user-input.tsx +270 -0
- package/src/components/search-web.tsx +319 -0
- package/src/components/sheet-command.tsx +88 -0
- package/src/components/shell-canvas.tsx +122 -0
- package/src/components/show-advanced-data-table.tsx +352 -0
- package/src/components/show-generated-content-options.tsx +93 -0
- package/src/components/show-people-cards.tsx +180 -0
- package/src/components/subagent-tool.tsx +180 -0
- package/src/components/text-editor-tool.tsx +328 -0
- package/src/components/work-canvas.tsx +88 -0
- package/src/components/work-card.tsx +42 -0
- package/src/declarations.d.ts +1 -0
- package/src/docy-assistant.tsx +1962 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/use-assistant-api.ts +507 -0
- package/src/hooks/use-deployment-data.ts +162 -0
- package/src/hooks/use-project-state.ts +347 -0
- package/src/hooks/use-session-state.ts +207 -0
- package/src/hooks/use-speech-recognition.ts +137 -0
- package/src/hooks/use-ui-state.ts +185 -0
- package/src/hooks/use-works-state.ts +146 -0
- package/src/i18n/context.tsx +253 -0
- package/src/i18n/index.ts +19 -0
- package/src/i18n/locales/de.json +198 -0
- package/src/i18n/locales/el.json +198 -0
- package/src/i18n/locales/en.json +226 -0
- package/src/i18n/locales/es.json +198 -0
- package/src/i18n/locales/fr.json +198 -0
- package/src/i18n/locales/it.json +198 -0
- package/src/i18n/locales/pt.json +198 -0
- package/src/i18n/locales/sl.json +198 -0
- package/src/i18n/locales/tr.json +211 -0
- package/src/i18n/types.ts +23 -0
- package/src/i18n/use-translation.ts +17 -0
- package/src/index.ts +18 -0
- package/src/internal/plate-editor/editor/auth-context.ts +11 -0
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +39 -0
- package/src/internal/plate-editor/editor/editor-kit.tsx +89 -0
- package/src/internal/plate-editor/editor/plate-editor.tsx +75 -0
- package/src/internal/plate-editor/editor/plate-types.ts +126 -0
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +172 -0
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +211 -0
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +26 -0
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +51 -0
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +24 -0
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +38 -0
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +6 -0
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +14 -0
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +17 -0
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +31 -0
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +23 -0
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +26 -0
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +8 -0
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +174 -0
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +68 -0
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +13 -0
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +27 -0
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +43 -0
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +6 -0
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +15 -0
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +12 -0
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +19 -0
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +47 -0
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +19 -0
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +22 -0
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +35 -0
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +24 -0
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +27 -0
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +18 -0
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +8 -0
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +10 -0
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +37 -0
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +53 -0
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +17 -0
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +95 -0
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +20 -0
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +22 -0
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +14 -0
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +9 -0
- package/src/internal/plate-editor/editor/transforms.ts +165 -0
- package/src/internal/plate-editor/editor/use-chat.ts +152 -0
- package/src/internal/plate-editor/hooks/index.ts +3 -0
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +31 -0
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +26 -0
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +21 -0
- package/src/internal/plate-editor/hooks/use-media-query.ts +44 -0
- package/src/internal/plate-editor/hooks/use-mounted.ts +18 -0
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +114 -0
- package/src/internal/plate-editor/hooks/use-upload-file.ts +81 -0
- package/src/internal/plate-editor/i18n/context.tsx +58 -0
- package/src/internal/plate-editor/i18n/index.ts +3 -0
- package/src/internal/plate-editor/i18n/locales/de.json +57 -0
- package/src/internal/plate-editor/i18n/locales/el.json +57 -0
- package/src/internal/plate-editor/i18n/locales/en.json +57 -0
- package/src/internal/plate-editor/i18n/locales/es.json +57 -0
- package/src/internal/plate-editor/i18n/locales/fr.json +57 -0
- package/src/internal/plate-editor/i18n/locales/it.json +57 -0
- package/src/internal/plate-editor/i18n/locales/pt.json +57 -0
- package/src/internal/plate-editor/i18n/locales/sl.json +57 -0
- package/src/internal/plate-editor/i18n/locales/tr.json +57 -0
- package/src/internal/plate-editor/i18n/types.ts +59 -0
- package/src/internal/plate-editor/i18n/use-translation.ts +22 -0
- package/src/internal/plate-editor/index.ts +39 -0
- package/src/internal/plate-editor/lib/ai-output-converter.ts +153 -0
- package/src/internal/plate-editor/lib/download-file.ts +17 -0
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +828 -0
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +41 -0
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +27 -0
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +147 -0
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +90 -0
- package/src/internal/plate-editor/plate-ui/avatar.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +106 -0
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +364 -0
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +556 -0
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +78 -0
- package/src/internal/plate-editor/plate-ui/block-list.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +557 -0
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +47 -0
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +469 -0
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +10 -0
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/button.tsx +190 -0
- package/src/internal/plate-editor/plate-ui/calendar.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +76 -0
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +54 -0
- package/src/internal/plate-editor/plate-ui/caption.tsx +48 -0
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +172 -0
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +228 -0
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/code-node.tsx +12 -0
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +65 -0
- package/src/internal/plate-editor/plate-ui/column-node.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/command.tsx +204 -0
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +12 -0
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +45 -0
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/comment.tsx +619 -0
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +43 -0
- package/src/internal/plate-editor/plate-ui/date-node.tsx +56 -0
- package/src/internal/plate-editor/plate-ui/dialog.tsx +426 -0
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +266 -0
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +40 -0
- package/src/internal/plate-editor/plate-ui/editor.tsx +148 -0
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +48 -0
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +626 -0
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +155 -0
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +226 -0
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +208 -0
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +157 -0
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +27 -0
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +1129 -0
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +129 -0
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +99 -0
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +211 -0
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +154 -0
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +20 -0
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +56 -0
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +9 -0
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +7 -0
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +18 -0
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +28 -0
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +124 -0
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +34 -0
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +409 -0
- package/src/internal/plate-editor/plate-ui/input.tsx +39 -0
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +260 -0
- package/src/internal/plate-editor/plate-ui/label.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +71 -0
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +15 -0
- package/src/internal/plate-editor/plate-ui/link-node.tsx +33 -0
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +30 -0
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +149 -0
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +179 -0
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +36 -0
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +21 -0
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +32 -0
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +103 -0
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +30 -0
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +37 -0
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +183 -0
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +441 -0
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +127 -0
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +229 -0
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +216 -0
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +73 -0
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +35 -0
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +119 -0
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +46 -0
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +79 -0
- package/src/internal/plate-editor/plate-ui/menu.tsx +532 -0
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +126 -0
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +34 -0
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +15 -0
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +16 -0
- package/src/internal/plate-editor/plate-ui/popover.tsx +77 -0
- package/src/internal/plate-editor/plate-ui/progress.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +81 -0
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +88 -0
- package/src/internal/plate-editor/plate-ui/separator.tsx +43 -0
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +435 -0
- package/src/internal/plate-editor/plate-ui/spinner.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +35 -0
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +168 -0
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/table-node.tsx +285 -0
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +254 -0
- package/src/internal/plate-editor/plate-ui/tabs.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/textarea.tsx +58 -0
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +142 -0
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +57 -0
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +50 -0
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +18 -0
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +33 -0
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/toggle.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +380 -0
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +149 -0
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +177 -0
- package/src/internal/plate-editor/types/index.ts +22 -0
- package/src/internal/plate-editor/vite.ts +284 -0
- package/src/internal/sheets/components/univer-sheets.tsx +1104 -0
- package/src/internal/sheets/i18n/context.tsx +183 -0
- package/src/internal/sheets/i18n/index.ts +19 -0
- package/src/internal/sheets/i18n/locales/de.json +21 -0
- package/src/internal/sheets/i18n/locales/el.json +21 -0
- package/src/internal/sheets/i18n/locales/en.json +21 -0
- package/src/internal/sheets/i18n/locales/es.json +21 -0
- package/src/internal/sheets/i18n/locales/fr.json +21 -0
- package/src/internal/sheets/i18n/locales/it.json +21 -0
- package/src/internal/sheets/i18n/locales/pt.json +21 -0
- package/src/internal/sheets/i18n/locales/sl.json +21 -0
- package/src/internal/sheets/i18n/locales/tr.json +21 -0
- package/src/internal/sheets/i18n/types.ts +23 -0
- package/src/internal/sheets/i18n/use-translation.ts +17 -0
- package/src/internal/sheets/index.ts +14 -0
- package/src/internal/sheets/types/css.d.ts +11 -0
- package/src/internal/sheets/types/index.ts +260 -0
- package/src/internal/sheets/xlsx.ts +1169 -0
- package/src/lib/api-client.ts +77 -0
- package/src/lib/assistant-api-actions.ts +549 -0
- package/src/lib/assistant-config.tsx +71 -0
- package/src/lib/class-utils.ts +40 -0
- package/src/lib/index.ts +7 -0
- package/src/lib/message-utils.ts +131 -0
- package/src/tools/tools-schema.json +512 -0
- package/src/types/index.ts +235 -0
- package/src/views/assistant-view.tsx +1137 -0
- package/src/views/canvas-app.tsx +839 -0
- package/src/views/canvas-code.tsx +93 -0
- package/src/views/canvas-deep-research.tsx +44 -0
- package/src/views/canvas-image.tsx +25 -0
- package/src/views/canvas-record-view.tsx +285 -0
- package/src/views/canvas-spreadsheet.tsx +125 -0
- package/src/views/canvas-text.tsx +52 -0
- package/src/views/canvas.tsx +274 -0
- package/src/views/chat-panel.tsx +149 -0
- package/src/views/index.ts +20 -0
- package/src/views/memories-panel.tsx +365 -0
- package/src/views/message-list.tsx +370 -0
- package/src/views/project-detail.tsx +257 -0
- package/src/views/projects-panel.tsx +131 -0
- package/src/views/sessions-list.tsx +98 -0
- package/src/views/sidebar-content.tsx +256 -0
- package/src/views/work-detail.tsx +98 -0
- package/src/vite.ts +284 -0
package/package.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@docyrus/ui-pro-ai-assistant",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Docyrus AI Assistant component — full-featured chat UI with canvas, projects, and i18n support.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./src/index.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"./vite": "./src/vite.ts"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@ai-sdk/react": "3.0.110",
|
|
24
|
+
"@codesandbox/sandpack-react": "2.20.0",
|
|
25
|
+
"@lottiefiles/dotlottie-react": "0.18.3",
|
|
26
|
+
"@visactor/vchart": "2.0.17",
|
|
27
|
+
"@visactor/vtable": "1.23.2",
|
|
28
|
+
"@visactor/vtable-plugins": "1.23.2",
|
|
29
|
+
"ai": "6.0.108",
|
|
30
|
+
"lucide-react": "0.576.0",
|
|
31
|
+
"mermaid": "11.12.3",
|
|
32
|
+
"recharts": "2.15.4",
|
|
33
|
+
"sonner": "2.0.7",
|
|
34
|
+
"@ariakit/react": "0.4.21",
|
|
35
|
+
"@emoji-mart/data": "1.2.1",
|
|
36
|
+
"@platejs/ai": "52.3.1",
|
|
37
|
+
"@platejs/autoformat": "52.0.11",
|
|
38
|
+
"@platejs/basic-nodes": "52.0.11",
|
|
39
|
+
"@platejs/basic-styles": "52.0.11",
|
|
40
|
+
"@platejs/callout": "52.0.11",
|
|
41
|
+
"@platejs/caption": "52.0.11",
|
|
42
|
+
"@platejs/code-block": "52.0.11",
|
|
43
|
+
"@platejs/combobox": "52.0.15",
|
|
44
|
+
"@platejs/comment": "52.0.11",
|
|
45
|
+
"@platejs/date": "52.0.11",
|
|
46
|
+
"@platejs/diff": "52.0.11",
|
|
47
|
+
"@platejs/dnd": "52.0.11",
|
|
48
|
+
"@platejs/docx": "52.0.11",
|
|
49
|
+
"@platejs/docx-io": "52.2.0",
|
|
50
|
+
"@platejs/emoji": "52.0.15",
|
|
51
|
+
"@platejs/floating": "52.0.11",
|
|
52
|
+
"@platejs/indent": "52.0.11",
|
|
53
|
+
"@platejs/juice": "52.0.11",
|
|
54
|
+
"@platejs/layout": "52.0.11",
|
|
55
|
+
"@platejs/link": "52.0.11",
|
|
56
|
+
"@platejs/list": "52.0.11",
|
|
57
|
+
"@platejs/markdown": "52.3.1",
|
|
58
|
+
"@platejs/math": "52.0.11",
|
|
59
|
+
"@platejs/media": "52.0.11",
|
|
60
|
+
"@platejs/mention": "52.0.15",
|
|
61
|
+
"@platejs/resizable": "52.0.11",
|
|
62
|
+
"@platejs/selection": "52.0.16",
|
|
63
|
+
"@platejs/slash-command": "52.0.15",
|
|
64
|
+
"@platejs/suggestion": "52.0.11",
|
|
65
|
+
"@platejs/table": "52.0.11",
|
|
66
|
+
"@platejs/toc": "52.0.11",
|
|
67
|
+
"@platejs/toggle": "52.0.11",
|
|
68
|
+
"class-variance-authority": "0.7.1",
|
|
69
|
+
"cmdk": "1.1.1",
|
|
70
|
+
"date-fns": "4.1.0",
|
|
71
|
+
"html2canvas-pro": "1.6.7",
|
|
72
|
+
"jotai-x": "2.3.3",
|
|
73
|
+
"lowlight": "3.3.0",
|
|
74
|
+
"pdf-lib": "1.17.1",
|
|
75
|
+
"platejs": "^52.3.2",
|
|
76
|
+
"radix-ui": "1.4.3",
|
|
77
|
+
"react-day-picker": "9.14.0",
|
|
78
|
+
"react-dnd": "16.0.1",
|
|
79
|
+
"react-dnd-html5-backend": "16.0.1",
|
|
80
|
+
"react-lite-youtube-embed": "3.5.1",
|
|
81
|
+
"react-player": "3.4.0",
|
|
82
|
+
"remark-gfm": "4.0.1",
|
|
83
|
+
"remark-math": "6.0.0",
|
|
84
|
+
"scroll-into-view-if-needed": "3.1.0",
|
|
85
|
+
"use-file-picker": "2.1.4",
|
|
86
|
+
"use-stick-to-bottom": "1.1.3",
|
|
87
|
+
"vaul": "1.1.2",
|
|
88
|
+
"@univerjs/core": "0.16.1",
|
|
89
|
+
"@univerjs/design": "0.16.1",
|
|
90
|
+
"@univerjs/docs": "0.16.1",
|
|
91
|
+
"@univerjs/docs-ui": "0.16.1",
|
|
92
|
+
"@univerjs/drawing": "0.16.1",
|
|
93
|
+
"@univerjs/drawing-ui": "0.16.1",
|
|
94
|
+
"@univerjs/engine-formula": "0.16.1",
|
|
95
|
+
"@univerjs/engine-render": "0.16.1",
|
|
96
|
+
"@univerjs/find-replace": "0.16.1",
|
|
97
|
+
"@univerjs/sheets": "0.16.1",
|
|
98
|
+
"@univerjs/sheets-conditional-formatting": "0.16.1",
|
|
99
|
+
"@univerjs/sheets-conditional-formatting-ui": "0.16.1",
|
|
100
|
+
"@univerjs/sheets-crosshair-highlight": "0.16.1",
|
|
101
|
+
"@univerjs/sheets-data-validation": "0.16.1",
|
|
102
|
+
"@univerjs/sheets-data-validation-ui": "0.16.1",
|
|
103
|
+
"@univerjs/sheets-drawing": "0.16.1",
|
|
104
|
+
"@univerjs/sheets-drawing-ui": "0.16.1",
|
|
105
|
+
"@univerjs/sheets-filter": "0.16.1",
|
|
106
|
+
"@univerjs/sheets-filter-ui": "0.16.1",
|
|
107
|
+
"@univerjs/sheets-find-replace": "0.16.1",
|
|
108
|
+
"@univerjs/sheets-formula": "0.16.1",
|
|
109
|
+
"@univerjs/sheets-formula-ui": "0.16.1",
|
|
110
|
+
"@univerjs/sheets-hyper-link": "0.16.1",
|
|
111
|
+
"@univerjs/sheets-hyper-link-ui": "0.16.1",
|
|
112
|
+
"@univerjs/sheets-numfmt": "0.16.1",
|
|
113
|
+
"@univerjs/sheets-numfmt-ui": "0.16.1",
|
|
114
|
+
"@univerjs/sheets-sort": "0.16.1",
|
|
115
|
+
"@univerjs/sheets-sort-ui": "0.16.1",
|
|
116
|
+
"@univerjs/sheets-thread-comment": "0.16.1",
|
|
117
|
+
"@univerjs/sheets-thread-comment-ui": "0.16.1",
|
|
118
|
+
"@univerjs/sheets-ui": "0.16.1",
|
|
119
|
+
"@univerjs/thread-comment": "0.16.1",
|
|
120
|
+
"@univerjs/thread-comment-ui": "0.16.1",
|
|
121
|
+
"@univerjs/ui": "0.16.1",
|
|
122
|
+
"@univerjs/watermark": "0.16.1",
|
|
123
|
+
"xlsx": "0.18.5"
|
|
124
|
+
},
|
|
125
|
+
"devDependencies": {
|
|
126
|
+
"@types/react": "19.2.14",
|
|
127
|
+
"@types/react-dom": "19.2.3",
|
|
128
|
+
"tsup": "8.5.1",
|
|
129
|
+
"typescript": "5.9.3",
|
|
130
|
+
"@types/node": "25.3.3",
|
|
131
|
+
"@docyrus/ui-pro-shared": "0.0.1"
|
|
132
|
+
},
|
|
133
|
+
"peerDependencies": {
|
|
134
|
+
"@docyrus/api-client": ">=0.1.0",
|
|
135
|
+
"@docyrus/ui-pro-shared": ">=0.0.1",
|
|
136
|
+
"react": "19.2.4",
|
|
137
|
+
"react-dom": "19.2.4",
|
|
138
|
+
"vite": ">=5.0.0"
|
|
139
|
+
},
|
|
140
|
+
"peerDependenciesMeta": {
|
|
141
|
+
"vite": {
|
|
142
|
+
"optional": true
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"publishConfig": {
|
|
146
|
+
"access": "public"
|
|
147
|
+
},
|
|
148
|
+
"license": "MIT",
|
|
149
|
+
"scripts": {
|
|
150
|
+
"build": "tsup",
|
|
151
|
+
"dev": "tsup --watch",
|
|
152
|
+
"typecheck": "tsc --noEmit",
|
|
153
|
+
"lint": "eslint src/"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
|
|
4
|
+
|
|
5
|
+
const ANIMATIONS = {
|
|
6
|
+
opening: '/lottie/docy/opening.lottie',
|
|
7
|
+
thinking: '/lottie/docy/thinking.lottie',
|
|
8
|
+
working: '/lottie/docy/working.lottie'
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
type AnimationType = keyof typeof ANIMATIONS;
|
|
12
|
+
|
|
13
|
+
interface AssistantAnimationsProps {
|
|
14
|
+
animationType?: AnimationType;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function AssistantAnimations({
|
|
19
|
+
animationType = 'thinking',
|
|
20
|
+
className
|
|
21
|
+
}: AssistantAnimationsProps) {
|
|
22
|
+
return (
|
|
23
|
+
<DotLottieReact
|
|
24
|
+
src={ANIMATIONS[animationType]}
|
|
25
|
+
autoplay
|
|
26
|
+
loop={animationType !== 'opening'}
|
|
27
|
+
className={className} />
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Button } from '@docyrus/ui-pro-shared/components/button';
|
|
4
|
+
import {
|
|
5
|
+
Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle
|
|
6
|
+
} from '@docyrus/ui-pro-shared/components/dialog';
|
|
7
|
+
import { Input } from '@docyrus/ui-pro-shared/components/input';
|
|
8
|
+
import { Textarea } from '@docyrus/ui-pro-shared/components/textarea';
|
|
9
|
+
|
|
10
|
+
import { type ProjectState } from '../hooks/use-project-state';
|
|
11
|
+
|
|
12
|
+
import { type SessionState } from '../hooks/use-session-state';
|
|
13
|
+
|
|
14
|
+
interface AssistantDialogsProps {
|
|
15
|
+
// Project state
|
|
16
|
+
projectState: ProjectState;
|
|
17
|
+
projectActions: {
|
|
18
|
+
startEditing: () => void;
|
|
19
|
+
stopEditing: () => void;
|
|
20
|
+
setName: (name: string) => void;
|
|
21
|
+
setDescription: (description: string) => void;
|
|
22
|
+
setDeleteDialogOpen: (open: boolean) => void;
|
|
23
|
+
startEditingInstructions: () => void;
|
|
24
|
+
stopEditingInstructions: () => void;
|
|
25
|
+
setInstructions: (instructions: string) => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Session state
|
|
29
|
+
sessionState: SessionState;
|
|
30
|
+
sessionActions: {
|
|
31
|
+
startEditing: () => void;
|
|
32
|
+
stopEditing: () => void;
|
|
33
|
+
setName: (name: string) => void;
|
|
34
|
+
setDeleteDialogOpen: (open: boolean) => void;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Actions
|
|
38
|
+
onUpdateProject: () => Promise<void>;
|
|
39
|
+
onDeleteProject: () => Promise<void>;
|
|
40
|
+
onUpdateSession: () => Promise<void>;
|
|
41
|
+
onDeleteSession: () => Promise<void>;
|
|
42
|
+
onUpdateProjectInstructions: () => Promise<void>;
|
|
43
|
+
|
|
44
|
+
// i18n
|
|
45
|
+
t: (key: string) => string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function AssistantDialogs({
|
|
49
|
+
projectState,
|
|
50
|
+
projectActions,
|
|
51
|
+
sessionState,
|
|
52
|
+
sessionActions,
|
|
53
|
+
onUpdateProject,
|
|
54
|
+
onDeleteProject,
|
|
55
|
+
onUpdateSession,
|
|
56
|
+
onDeleteSession,
|
|
57
|
+
onUpdateProjectInstructions,
|
|
58
|
+
t
|
|
59
|
+
}: AssistantDialogsProps) {
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{/* Edit Project Dialog */}
|
|
63
|
+
<Dialog
|
|
64
|
+
open={projectState.isEditing}
|
|
65
|
+
onOpenChange={open => (open ? projectActions.startEditing() : projectActions.stopEditing())}>
|
|
66
|
+
<DialogContent className="sm:max-w-md z-[200]">
|
|
67
|
+
<DialogHeader>
|
|
68
|
+
<DialogTitle>{t('dialogs.edit_project')}</DialogTitle>
|
|
69
|
+
</DialogHeader>
|
|
70
|
+
<div className="space-y-4 py-4">
|
|
71
|
+
<div className="space-y-2">
|
|
72
|
+
<label htmlFor="project-name" className="text-sm font-medium leading-none">
|
|
73
|
+
{t('labels.project_name')}
|
|
74
|
+
</label>
|
|
75
|
+
<Input
|
|
76
|
+
id="project-name"
|
|
77
|
+
value={projectState.name}
|
|
78
|
+
onChange={e => projectActions.setName(e.target.value)}
|
|
79
|
+
placeholder={t('placeholders.enter_project_name')} />
|
|
80
|
+
</div>
|
|
81
|
+
<div className="space-y-2">
|
|
82
|
+
<label htmlFor="project-description" className="text-sm font-medium leading-none">
|
|
83
|
+
{t('labels.description')}
|
|
84
|
+
</label>
|
|
85
|
+
<Textarea
|
|
86
|
+
className="resize-none"
|
|
87
|
+
id="project-description"
|
|
88
|
+
value={projectState.description}
|
|
89
|
+
onChange={e => projectActions.setDescription(e.target.value)}
|
|
90
|
+
placeholder={t('placeholders.enter_project_description')}
|
|
91
|
+
rows={3} />
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<DialogFooter>
|
|
95
|
+
<Button className="cursor-pointer" variant="outline" onClick={() => projectActions.stopEditing()}>
|
|
96
|
+
{t('buttons.cancel')}
|
|
97
|
+
</Button>
|
|
98
|
+
<Button
|
|
99
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90 cursor-pointer"
|
|
100
|
+
onClick={onUpdateProject}
|
|
101
|
+
disabled={projectState.isSaving || !projectState.name.trim()}>
|
|
102
|
+
{projectState.isSaving ? t('buttons.saving') : t('buttons.save_changes')}
|
|
103
|
+
</Button>
|
|
104
|
+
</DialogFooter>
|
|
105
|
+
</DialogContent>
|
|
106
|
+
</Dialog>
|
|
107
|
+
|
|
108
|
+
{/* Delete Project Dialog */}
|
|
109
|
+
<Dialog open={projectState.isDeleteDialogOpen} onOpenChange={projectActions.setDeleteDialogOpen}>
|
|
110
|
+
<DialogContent className="sm:max-w-md z-[200]">
|
|
111
|
+
<DialogHeader>
|
|
112
|
+
<DialogTitle>{t('dialogs.delete_project')}</DialogTitle>
|
|
113
|
+
</DialogHeader>
|
|
114
|
+
<div className="space-y-4 py-4">
|
|
115
|
+
<p>{t('messages.delete_project_confirm')}</p>
|
|
116
|
+
</div>
|
|
117
|
+
<DialogFooter>
|
|
118
|
+
<Button
|
|
119
|
+
className="cursor-pointer"
|
|
120
|
+
variant="outline"
|
|
121
|
+
onClick={() => projectActions.setDeleteDialogOpen(false)}>
|
|
122
|
+
{t('buttons.cancel')}
|
|
123
|
+
</Button>
|
|
124
|
+
<Button
|
|
125
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90 cursor-pointer"
|
|
126
|
+
onClick={onDeleteProject}
|
|
127
|
+
disabled={projectState.isDeleting}>
|
|
128
|
+
{projectState.isDeleting ? t('buttons.deleting') : t('buttons.delete_project')}
|
|
129
|
+
</Button>
|
|
130
|
+
</DialogFooter>
|
|
131
|
+
</DialogContent>
|
|
132
|
+
</Dialog>
|
|
133
|
+
|
|
134
|
+
{/* Edit Session Dialog */}
|
|
135
|
+
<Dialog
|
|
136
|
+
open={sessionState.isEditing}
|
|
137
|
+
onOpenChange={open => (open ? sessionActions.startEditing() : sessionActions.stopEditing())}>
|
|
138
|
+
<DialogContent className="sm:max-w-md z-[200]">
|
|
139
|
+
<DialogHeader>
|
|
140
|
+
<DialogTitle>{t('dialogs.rename_session')}</DialogTitle>
|
|
141
|
+
</DialogHeader>
|
|
142
|
+
<div className="space-y-4 py-4">
|
|
143
|
+
<div className="space-y-2">
|
|
144
|
+
<label htmlFor="session-name" className="text-sm font-medium leading-none">
|
|
145
|
+
{t('labels.session_name')}
|
|
146
|
+
</label>
|
|
147
|
+
<Input
|
|
148
|
+
id="session-name"
|
|
149
|
+
value={sessionState.name}
|
|
150
|
+
onChange={e => sessionActions.setName(e.target.value)}
|
|
151
|
+
placeholder={t('placeholders.enter_session_name')} />
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
<DialogFooter>
|
|
155
|
+
<Button className="cursor-pointer" variant="outline" onClick={() => sessionActions.stopEditing()}>
|
|
156
|
+
{t('buttons.cancel')}
|
|
157
|
+
</Button>
|
|
158
|
+
<Button
|
|
159
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90 cursor-pointer"
|
|
160
|
+
onClick={onUpdateSession}
|
|
161
|
+
disabled={sessionState.isSaving || !sessionState.name.trim()}>
|
|
162
|
+
{sessionState.isSaving ? t('buttons.saving') : t('buttons.save_changes')}
|
|
163
|
+
</Button>
|
|
164
|
+
</DialogFooter>
|
|
165
|
+
</DialogContent>
|
|
166
|
+
</Dialog>
|
|
167
|
+
|
|
168
|
+
{/* Delete Session Dialog */}
|
|
169
|
+
<Dialog open={sessionState.isDeleteDialogOpen} onOpenChange={sessionActions.setDeleteDialogOpen}>
|
|
170
|
+
<DialogContent className="sm:max-w-md z-[200]">
|
|
171
|
+
<DialogHeader>
|
|
172
|
+
<DialogTitle>{t('dialogs.delete_session')}</DialogTitle>
|
|
173
|
+
</DialogHeader>
|
|
174
|
+
<div className="space-y-4 py-4">
|
|
175
|
+
<p>{t('messages.delete_session_confirm')}</p>
|
|
176
|
+
</div>
|
|
177
|
+
<DialogFooter>
|
|
178
|
+
<Button
|
|
179
|
+
className="cursor-pointer"
|
|
180
|
+
variant="outline"
|
|
181
|
+
onClick={() => sessionActions.setDeleteDialogOpen(false)}>
|
|
182
|
+
{t('buttons.cancel')}
|
|
183
|
+
</Button>
|
|
184
|
+
<Button
|
|
185
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90 cursor-pointer"
|
|
186
|
+
onClick={onDeleteSession}
|
|
187
|
+
disabled={sessionState.isDeleting}>
|
|
188
|
+
{sessionState.isDeleting ? t('buttons.deleting') : t('buttons.delete_session')}
|
|
189
|
+
</Button>
|
|
190
|
+
</DialogFooter>
|
|
191
|
+
</DialogContent>
|
|
192
|
+
</Dialog>
|
|
193
|
+
|
|
194
|
+
{/* Edit Project Instructions Dialog */}
|
|
195
|
+
<Dialog
|
|
196
|
+
open={projectState.isEditingInstructions}
|
|
197
|
+
onOpenChange={open => open ? projectActions.startEditingInstructions() : projectActions.stopEditingInstructions()}>
|
|
198
|
+
<DialogContent className="sm:max-w-lg z-[200]">
|
|
199
|
+
<DialogHeader>
|
|
200
|
+
<DialogTitle>{t('dialogs.edit_instructions')}</DialogTitle>
|
|
201
|
+
</DialogHeader>
|
|
202
|
+
<div className="space-y-4 py-4">
|
|
203
|
+
<div className="space-y-2">
|
|
204
|
+
<label htmlFor="project-instructions" className="text-sm font-medium leading-none">
|
|
205
|
+
{t('sections.instructions')}
|
|
206
|
+
</label>
|
|
207
|
+
<Textarea
|
|
208
|
+
id="project-instructions"
|
|
209
|
+
value={projectState.instructions}
|
|
210
|
+
onChange={e => projectActions.setInstructions(e.target.value)}
|
|
211
|
+
placeholder={t('placeholders.add_instructions')}
|
|
212
|
+
className="min-h-30 resize-none"
|
|
213
|
+
rows={6} />
|
|
214
|
+
<p className="text-xs text-muted-foreground">{t('descriptions.instructions_help')}</p>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
<DialogFooter>
|
|
218
|
+
<Button
|
|
219
|
+
className="cursor-pointer"
|
|
220
|
+
variant="outline"
|
|
221
|
+
onClick={() => projectActions.stopEditingInstructions()}>
|
|
222
|
+
{t('buttons.cancel')}
|
|
223
|
+
</Button>
|
|
224
|
+
<Button
|
|
225
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90 cursor-pointer"
|
|
226
|
+
onClick={onUpdateProjectInstructions}
|
|
227
|
+
disabled={projectState.isSavingInstructions}>
|
|
228
|
+
{projectState.isSavingInstructions ? t('buttons.saving') : t('buttons.save_instructions')}
|
|
229
|
+
</Button>
|
|
230
|
+
</DialogFooter>
|
|
231
|
+
</DialogContent>
|
|
232
|
+
</Dialog>
|
|
233
|
+
</>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Component,
|
|
5
|
+
type ErrorInfo,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
useMemo
|
|
8
|
+
} from 'react';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
SandpackCodeEditor,
|
|
12
|
+
type SandpackFiles,
|
|
13
|
+
SandpackPreview,
|
|
14
|
+
SandpackProvider,
|
|
15
|
+
type SandpackPredefinedTemplate
|
|
16
|
+
} from '@codesandbox/sandpack-react';
|
|
17
|
+
import {
|
|
18
|
+
Sandbox,
|
|
19
|
+
SandboxContent,
|
|
20
|
+
SandboxTabContent,
|
|
21
|
+
SandboxTabs,
|
|
22
|
+
SandboxTabsBar,
|
|
23
|
+
SandboxTabsList,
|
|
24
|
+
SandboxTabsTrigger
|
|
25
|
+
} from '@docyrus/ui-pro-shared/ai-elements/sandbox';
|
|
26
|
+
import { Loader2 } from 'lucide-react';
|
|
27
|
+
|
|
28
|
+
import { useAssistantTranslation } from '../i18n';
|
|
29
|
+
|
|
30
|
+
type ToolState
|
|
31
|
+
= 'input-available'
|
|
32
|
+
| 'input-streaming'
|
|
33
|
+
| 'output-available'
|
|
34
|
+
| 'output-error'
|
|
35
|
+
| 'approval-requested'
|
|
36
|
+
| 'approval-responded'
|
|
37
|
+
| 'output-denied';
|
|
38
|
+
|
|
39
|
+
type SandpackLanguage
|
|
40
|
+
= 'react-ts'
|
|
41
|
+
| 'react'
|
|
42
|
+
| 'vanilla-ts'
|
|
43
|
+
| 'vanilla'
|
|
44
|
+
| 'vue'
|
|
45
|
+
| 'svelte'
|
|
46
|
+
| 'static';
|
|
47
|
+
|
|
48
|
+
export interface CodeViewFile {
|
|
49
|
+
path: string;
|
|
50
|
+
content: string;
|
|
51
|
+
active?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface CodeViewInput {
|
|
55
|
+
title?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
language?: SandpackLanguage;
|
|
58
|
+
files?: CodeViewFile[];
|
|
59
|
+
code?: string;
|
|
60
|
+
entryFile?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface CodeViewPart {
|
|
64
|
+
state: ToolState;
|
|
65
|
+
input?: CodeViewInput;
|
|
66
|
+
output?: {
|
|
67
|
+
id?: string;
|
|
68
|
+
files?: CodeViewFile[];
|
|
69
|
+
};
|
|
70
|
+
toolCallId: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface CodeViewProps {
|
|
74
|
+
part: CodeViewPart;
|
|
75
|
+
codeOnly?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function buildSandpackFiles(
|
|
79
|
+
files?: CodeViewFile[],
|
|
80
|
+
code?: string,
|
|
81
|
+
language?: SandpackLanguage
|
|
82
|
+
): SandpackFiles {
|
|
83
|
+
// If files array is provided, use it directly
|
|
84
|
+
if (files && files.length > 0) {
|
|
85
|
+
return files.reduce<SandpackFiles>((acc, file) => {
|
|
86
|
+
acc[file.path] = { code: file.content, active: file.active };
|
|
87
|
+
|
|
88
|
+
return acc;
|
|
89
|
+
}, {});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Fallback to single code content
|
|
93
|
+
if (!code) {
|
|
94
|
+
return {
|
|
95
|
+
'/App.tsx': {
|
|
96
|
+
code: 'export default function App() {\n return <h1>No content</h1>\n}',
|
|
97
|
+
active: true
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Build files based on language
|
|
103
|
+
switch (language) {
|
|
104
|
+
case 'react':
|
|
105
|
+
return {
|
|
106
|
+
'/App.js': { code, active: true }
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
case 'vanilla-ts':
|
|
110
|
+
return {
|
|
111
|
+
'/index.ts': { code, active: true }
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
case 'vanilla':
|
|
115
|
+
return {
|
|
116
|
+
'/index.js': { code, active: true }
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
case 'static':
|
|
120
|
+
return {
|
|
121
|
+
'/index.html': { code, active: true }
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
case 'react-ts':
|
|
125
|
+
|
|
126
|
+
default:
|
|
127
|
+
return {
|
|
128
|
+
'/App.tsx': { code, active: true }
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function getTemplate(language?: SandpackLanguage): SandpackPredefinedTemplate {
|
|
134
|
+
switch (language) {
|
|
135
|
+
case 'react':
|
|
136
|
+
return 'react';
|
|
137
|
+
|
|
138
|
+
case 'vanilla-ts':
|
|
139
|
+
return 'vanilla-ts';
|
|
140
|
+
|
|
141
|
+
case 'vanilla':
|
|
142
|
+
return 'vanilla';
|
|
143
|
+
|
|
144
|
+
case 'vue':
|
|
145
|
+
return 'vue';
|
|
146
|
+
|
|
147
|
+
case 'svelte':
|
|
148
|
+
return 'svelte';
|
|
149
|
+
|
|
150
|
+
case 'static':
|
|
151
|
+
return 'static';
|
|
152
|
+
|
|
153
|
+
case 'react-ts':
|
|
154
|
+
|
|
155
|
+
default:
|
|
156
|
+
return 'react-ts';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class SandpackErrorBoundary extends Component<
|
|
161
|
+
{ children: ReactNode },
|
|
162
|
+
{ error: string | null }
|
|
163
|
+
> {
|
|
164
|
+
constructor(props: { children: ReactNode }) {
|
|
165
|
+
super(props);
|
|
166
|
+
this.state = { error: null };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static getDerivedStateFromError(error: unknown) {
|
|
170
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
171
|
+
|
|
172
|
+
return { error: message };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
componentDidCatch(_error: unknown, _info: ErrorInfo) {
|
|
176
|
+
// silently caught
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
render() {
|
|
180
|
+
if (this.state.error) {
|
|
181
|
+
return (
|
|
182
|
+
<div className="flex items-center justify-center p-8 text-sm text-destructive">
|
|
183
|
+
Preview unavailable: {this.state.error}
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return this.props.children;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function CodeView({ part, codeOnly = false }: CodeViewProps) {
|
|
193
|
+
const { t } = useAssistantTranslation();
|
|
194
|
+
const { state, input, output } = part;
|
|
195
|
+
|
|
196
|
+
// Use output files if available (after processing), otherwise input
|
|
197
|
+
const files = useMemo(
|
|
198
|
+
() => buildSandpackFiles(
|
|
199
|
+
output?.files ?? input?.files,
|
|
200
|
+
input?.code,
|
|
201
|
+
input?.language
|
|
202
|
+
),
|
|
203
|
+
[
|
|
204
|
+
output?.files,
|
|
205
|
+
input?.files,
|
|
206
|
+
input?.code,
|
|
207
|
+
input?.language
|
|
208
|
+
]
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
const template = getTemplate(input?.language);
|
|
212
|
+
const isLoading = state === 'input-streaming';
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<Sandbox>
|
|
216
|
+
<SandboxContent>
|
|
217
|
+
{isLoading ? (
|
|
218
|
+
<div className="flex items-center justify-center p-8 text-muted-foreground">
|
|
219
|
+
<Loader2 className="size-5 animate-spin mr-2" />
|
|
220
|
+
<span>{t('code_view.generating')}</span>
|
|
221
|
+
</div>
|
|
222
|
+
) : (
|
|
223
|
+
<SandpackProvider
|
|
224
|
+
key={part.toolCallId}
|
|
225
|
+
template={template}
|
|
226
|
+
files={files}
|
|
227
|
+
theme="light"
|
|
228
|
+
options={{
|
|
229
|
+
externalResources: ['https://cdn.tailwindcss.com'],
|
|
230
|
+
bundlerTimeOut: 60000,
|
|
231
|
+
recompileMode: 'delayed',
|
|
232
|
+
recompileDelay: 500
|
|
233
|
+
}}
|
|
234
|
+
customSetup={(template === 'react-ts' || template === 'react') ? {
|
|
235
|
+
dependencies: {
|
|
236
|
+
'@docyrus/addin-client': '^0.0.8',
|
|
237
|
+
'@hugeicons/react': '^1.1.4',
|
|
238
|
+
'@hugeicons/core-free-icons': '^3.1.1',
|
|
239
|
+
'date-fns': '^4.1.0',
|
|
240
|
+
numbro: '^2.5.0',
|
|
241
|
+
'@docyrus/shadcn': '^0.1.0',
|
|
242
|
+
'class-variance-authority': '^0.7.1',
|
|
243
|
+
'tailwind-merge': '^3.4.0',
|
|
244
|
+
'tailwindcss-animate': '^1.0.7',
|
|
245
|
+
'tw-animate-css': '^1.4.0',
|
|
246
|
+
'lucide-react': '^0.275.0',
|
|
247
|
+
recharts: '^3.5.1',
|
|
248
|
+
'react-is': '^19.2.1'
|
|
249
|
+
}
|
|
250
|
+
} : undefined}>
|
|
251
|
+
{codeOnly ? (
|
|
252
|
+
<SandpackCodeEditor showTabs showLineNumbers showInlineErrors className="min-h-[400px]" />
|
|
253
|
+
) : (
|
|
254
|
+
<SandboxTabs defaultValue="code">
|
|
255
|
+
<SandboxTabsBar>
|
|
256
|
+
<SandboxTabsList>
|
|
257
|
+
<SandboxTabsTrigger value="code">{t('tabs.code')}</SandboxTabsTrigger>
|
|
258
|
+
<SandboxTabsTrigger value="preview">{t('tabs.preview')}</SandboxTabsTrigger>
|
|
259
|
+
</SandboxTabsList>
|
|
260
|
+
</SandboxTabsBar>
|
|
261
|
+
|
|
262
|
+
<SandboxTabContent value="code">
|
|
263
|
+
<SandpackCodeEditor showTabs showLineNumbers showInlineErrors className="min-h-[400px]" />
|
|
264
|
+
</SandboxTabContent>
|
|
265
|
+
|
|
266
|
+
<SandboxTabContent value="preview">
|
|
267
|
+
<SandpackErrorBoundary>
|
|
268
|
+
<SandpackPreview showNavigator={false} showRefreshButton className="min-h-[400px]" />
|
|
269
|
+
</SandpackErrorBoundary>
|
|
270
|
+
</SandboxTabContent>
|
|
271
|
+
</SandboxTabs>
|
|
272
|
+
)}
|
|
273
|
+
</SandpackProvider>
|
|
274
|
+
)}
|
|
275
|
+
</SandboxContent>
|
|
276
|
+
</Sandbox>
|
|
277
|
+
);
|
|
278
|
+
}
|