@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.5
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/components/assistant-animations.d.ts +3 -3
- package/dist/docy-assistant.d.ts +1 -1
- package/dist/index.js +74 -47
- package/dist/index.js.map +1 -1
- package/dist/styles.css +5137 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/views/assistant-view.d.ts +2 -2
- package/package.json +38 -36
- package/src/components/assistant-animations.tsx +0 -29
- package/src/components/assistant-dialogs.tsx +0 -235
- package/src/components/code-view.tsx +0 -278
- package/src/components/create-agent-task.tsx +0 -104
- package/src/components/create-new-work-version.tsx +0 -30
- package/src/components/extract-web.tsx +0 -160
- package/src/components/forward-to-agent.tsx +0 -90
- package/src/components/generate-chart.tsx +0 -101
- package/src/components/generative-action-button.tsx +0 -122
- package/src/components/generative-tool.tsx +0 -685
- package/src/components/generative-ui-object.tsx +0 -210
- package/src/components/input-area.tsx +0 -1209
- package/src/components/json-schema-layout.tsx +0 -326
- package/src/components/list-item-card.tsx +0 -92
- package/src/components/mermaid-diagram.tsx +0 -192
- package/src/components/preview-image.tsx +0 -47
- package/src/components/request-approval.tsx +0 -48
- package/src/components/request-user-input.tsx +0 -270
- package/src/components/search-web.tsx +0 -319
- package/src/components/sheet-command.tsx +0 -88
- package/src/components/shell-canvas.tsx +0 -122
- package/src/components/show-advanced-data-table.tsx +0 -352
- package/src/components/show-generated-content-options.tsx +0 -93
- package/src/components/show-people-cards.tsx +0 -180
- package/src/components/subagent-tool.tsx +0 -180
- package/src/components/text-editor-tool.tsx +0 -328
- package/src/components/work-canvas.tsx +0 -88
- package/src/components/work-card.tsx +0 -42
- package/src/declarations.d.ts +0 -1
- package/src/docy-assistant.tsx +0 -1962
- package/src/hooks/index.ts +0 -7
- package/src/hooks/use-assistant-api.ts +0 -507
- package/src/hooks/use-deployment-data.ts +0 -162
- package/src/hooks/use-project-state.ts +0 -347
- package/src/hooks/use-session-state.ts +0 -207
- package/src/hooks/use-speech-recognition.ts +0 -137
- package/src/hooks/use-ui-state.ts +0 -185
- package/src/hooks/use-works-state.ts +0 -146
- package/src/i18n/context.tsx +0 -253
- package/src/i18n/index.ts +0 -19
- package/src/i18n/locales/de.json +0 -198
- package/src/i18n/locales/el.json +0 -198
- package/src/i18n/locales/en.json +0 -226
- package/src/i18n/locales/es.json +0 -198
- package/src/i18n/locales/fr.json +0 -198
- package/src/i18n/locales/it.json +0 -198
- package/src/i18n/locales/pt.json +0 -198
- package/src/i18n/locales/sl.json +0 -198
- package/src/i18n/locales/tr.json +0 -211
- package/src/i18n/types.ts +0 -23
- package/src/i18n/use-translation.ts +0 -17
- package/src/index.ts +0 -18
- package/src/internal/plate-editor/editor/auth-context.ts +0 -11
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +0 -39
- package/src/internal/plate-editor/editor/editor-kit.tsx +0 -89
- package/src/internal/plate-editor/editor/plate-editor.tsx +0 -75
- package/src/internal/plate-editor/editor/plate-types.ts +0 -126
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +0 -172
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +0 -211
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +0 -51
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +0 -38
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +0 -31
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +0 -23
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +0 -174
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +0 -68
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +0 -13
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +0 -43
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +0 -15
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +0 -12
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +0 -47
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +0 -35
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +0 -18
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +0 -10
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +0 -37
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +0 -53
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +0 -95
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +0 -20
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +0 -9
- package/src/internal/plate-editor/editor/transforms.ts +0 -165
- package/src/internal/plate-editor/editor/use-chat.ts +0 -152
- package/src/internal/plate-editor/hooks/index.ts +0 -3
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +0 -31
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +0 -26
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +0 -21
- package/src/internal/plate-editor/hooks/use-media-query.ts +0 -44
- package/src/internal/plate-editor/hooks/use-mounted.ts +0 -18
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +0 -114
- package/src/internal/plate-editor/hooks/use-upload-file.ts +0 -81
- package/src/internal/plate-editor/i18n/context.tsx +0 -58
- package/src/internal/plate-editor/i18n/index.ts +0 -3
- package/src/internal/plate-editor/i18n/locales/de.json +0 -57
- package/src/internal/plate-editor/i18n/locales/el.json +0 -57
- package/src/internal/plate-editor/i18n/locales/en.json +0 -57
- package/src/internal/plate-editor/i18n/locales/es.json +0 -57
- package/src/internal/plate-editor/i18n/locales/fr.json +0 -57
- package/src/internal/plate-editor/i18n/locales/it.json +0 -57
- package/src/internal/plate-editor/i18n/locales/pt.json +0 -57
- package/src/internal/plate-editor/i18n/locales/sl.json +0 -57
- package/src/internal/plate-editor/i18n/locales/tr.json +0 -57
- package/src/internal/plate-editor/i18n/types.ts +0 -59
- package/src/internal/plate-editor/i18n/use-translation.ts +0 -22
- package/src/internal/plate-editor/index.ts +0 -39
- package/src/internal/plate-editor/lib/ai-output-converter.ts +0 -153
- package/src/internal/plate-editor/lib/download-file.ts +0 -17
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +0 -828
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +0 -145
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +0 -88
- package/src/internal/plate-editor/plate-ui/avatar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +0 -104
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +0 -364
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +0 -557
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +0 -77
- package/src/internal/plate-editor/plate-ui/block-list.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +0 -555
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +0 -469
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +0 -10
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/button.tsx +0 -201
- package/src/internal/plate-editor/plate-ui/calendar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +0 -76
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/caption.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +0 -172
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/code-node.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +0 -65
- package/src/internal/plate-editor/plate-ui/column-node.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/command.tsx +0 -202
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +0 -45
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/comment.tsx +0 -619
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +0 -43
- package/src/internal/plate-editor/plate-ui/date-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/dialog.tsx +0 -445
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +0 -264
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +0 -40
- package/src/internal/plate-editor/plate-ui/editor.tsx +0 -146
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +0 -626
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +0 -155
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +0 -26
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +0 -206
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +0 -157
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +0 -1129
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +0 -129
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +0 -97
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +0 -209
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +0 -152
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +0 -20
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +0 -56
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +0 -9
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +0 -50
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +0 -7
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +0 -122
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +0 -409
- package/src/internal/plate-editor/plate-ui/input.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +0 -258
- package/src/internal/plate-editor/plate-ui/label.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +0 -69
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/link-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +0 -147
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +0 -177
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +0 -21
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +0 -103
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +0 -30
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +0 -183
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +0 -441
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +0 -127
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +0 -227
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +0 -214
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +0 -73
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +0 -119
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +0 -46
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/menu.tsx +0 -539
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +0 -124
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +0 -16
- package/src/internal/plate-editor/plate-ui/popover.tsx +0 -75
- package/src/internal/plate-editor/plate-ui/progress.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +0 -86
- package/src/internal/plate-editor/plate-ui/separator.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +0 -433
- package/src/internal/plate-editor/plate-ui/spinner.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +0 -166
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +0 -84
- package/src/internal/plate-editor/plate-ui/table-node.tsx +0 -283
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +0 -252
- package/src/internal/plate-editor/plate-ui/tabs.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/textarea.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +0 -142
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/toggle.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +0 -378
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +0 -148
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +0 -175
- package/src/internal/plate-editor/types/index.ts +0 -22
- package/src/internal/plate-editor/vite.ts +0 -284
- package/src/internal/sheets/components/univer-sheets.tsx +0 -1104
- package/src/internal/sheets/i18n/context.tsx +0 -183
- package/src/internal/sheets/i18n/index.ts +0 -19
- package/src/internal/sheets/i18n/locales/de.json +0 -21
- package/src/internal/sheets/i18n/locales/el.json +0 -21
- package/src/internal/sheets/i18n/locales/en.json +0 -21
- package/src/internal/sheets/i18n/locales/es.json +0 -21
- package/src/internal/sheets/i18n/locales/fr.json +0 -21
- package/src/internal/sheets/i18n/locales/it.json +0 -21
- package/src/internal/sheets/i18n/locales/pt.json +0 -21
- package/src/internal/sheets/i18n/locales/sl.json +0 -21
- package/src/internal/sheets/i18n/locales/tr.json +0 -21
- package/src/internal/sheets/i18n/types.ts +0 -23
- package/src/internal/sheets/i18n/use-translation.ts +0 -17
- package/src/internal/sheets/index.ts +0 -14
- package/src/internal/sheets/types/css.d.ts +0 -11
- package/src/internal/sheets/types/index.ts +0 -260
- package/src/internal/sheets/xlsx.ts +0 -1169
- package/src/lib/api-client.ts +0 -77
- package/src/lib/assistant-api-actions.ts +0 -549
- package/src/lib/assistant-config.tsx +0 -75
- package/src/lib/class-utils.ts +0 -40
- package/src/lib/index.ts +0 -7
- package/src/lib/message-utils.ts +0 -131
- package/src/tools/tools-schema.json +0 -512
- package/src/types/index.ts +0 -235
- package/src/views/assistant-view.tsx +0 -1137
- package/src/views/canvas-app.tsx +0 -839
- package/src/views/canvas-code.tsx +0 -93
- package/src/views/canvas-deep-research.tsx +0 -44
- package/src/views/canvas-image.tsx +0 -25
- package/src/views/canvas-record-view.tsx +0 -285
- package/src/views/canvas-spreadsheet.tsx +0 -125
- package/src/views/canvas-text.tsx +0 -52
- package/src/views/canvas.tsx +0 -274
- package/src/views/chat-panel.tsx +0 -149
- package/src/views/index.ts +0 -20
- package/src/views/memories-panel.tsx +0 -365
- package/src/views/message-list.tsx +0 -370
- package/src/views/project-detail.tsx +0 -257
- package/src/views/projects-panel.tsx +0 -131
- package/src/views/sessions-list.tsx +0 -98
- package/src/views/sidebar-content.tsx +0 -256
- package/src/views/work-detail.tsx +0 -98
- package/src/vite.ts +0 -64
- package/src/worker.ts +0 -203
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import { CodeView, type CodeViewPart } from '../components/code-view';
|
|
4
|
-
|
|
5
|
-
type SandpackLanguage
|
|
6
|
-
= 'react-ts'
|
|
7
|
-
| 'react'
|
|
8
|
-
| 'vanilla-ts'
|
|
9
|
-
| 'vanilla'
|
|
10
|
-
| 'vue'
|
|
11
|
-
| 'svelte'
|
|
12
|
-
| 'static';
|
|
13
|
-
|
|
14
|
-
type InputLanguage
|
|
15
|
-
= SandpackLanguage
|
|
16
|
-
| 'typescript'
|
|
17
|
-
| 'javascript'
|
|
18
|
-
| 'html'
|
|
19
|
-
| 'css'
|
|
20
|
-
| 'json'
|
|
21
|
-
| 'sql'
|
|
22
|
-
| 'markdown'
|
|
23
|
-
| 'text';
|
|
24
|
-
|
|
25
|
-
interface CanvasCodeViewProps {
|
|
26
|
-
contentText?: string;
|
|
27
|
-
language?: InputLanguage;
|
|
28
|
-
title?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function mapToSandpackLanguage(lang?: InputLanguage): SandpackLanguage {
|
|
32
|
-
switch (lang) {
|
|
33
|
-
case 'typescript':
|
|
34
|
-
|
|
35
|
-
case 'react-ts':
|
|
36
|
-
return 'react-ts';
|
|
37
|
-
|
|
38
|
-
case 'javascript':
|
|
39
|
-
|
|
40
|
-
case 'react':
|
|
41
|
-
return 'react';
|
|
42
|
-
|
|
43
|
-
case 'html':
|
|
44
|
-
|
|
45
|
-
case 'css':
|
|
46
|
-
|
|
47
|
-
case 'json':
|
|
48
|
-
|
|
49
|
-
case 'sql':
|
|
50
|
-
|
|
51
|
-
case 'markdown':
|
|
52
|
-
|
|
53
|
-
case 'text':
|
|
54
|
-
return 'static';
|
|
55
|
-
|
|
56
|
-
case 'vue':
|
|
57
|
-
return 'vue';
|
|
58
|
-
|
|
59
|
-
case 'svelte':
|
|
60
|
-
return 'svelte';
|
|
61
|
-
|
|
62
|
-
case 'vanilla-ts':
|
|
63
|
-
return 'vanilla-ts';
|
|
64
|
-
|
|
65
|
-
case 'vanilla':
|
|
66
|
-
return 'vanilla';
|
|
67
|
-
|
|
68
|
-
default:
|
|
69
|
-
return 'react-ts';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function CanvasCodeView({
|
|
74
|
-
contentText = '',
|
|
75
|
-
language = 'react-ts',
|
|
76
|
-
title = 'Code Preview'
|
|
77
|
-
}: CanvasCodeViewProps) {
|
|
78
|
-
const sandpackLanguage = mapToSandpackLanguage(language);
|
|
79
|
-
|
|
80
|
-
const part: CodeViewPart = useMemo(() => ({
|
|
81
|
-
state: 'output-available',
|
|
82
|
-
toolCallId: 'canvas-code',
|
|
83
|
-
input: {
|
|
84
|
-
title,
|
|
85
|
-
language: sandpackLanguage,
|
|
86
|
-
code: contentText
|
|
87
|
-
}
|
|
88
|
-
}), [contentText, sandpackLanguage, title]);
|
|
89
|
-
|
|
90
|
-
return <CodeView part={part} codeOnly />;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export default CanvasCodeView;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { JsonSchemaLayout } from '../components/json-schema-layout';
|
|
4
|
-
|
|
5
|
-
export interface CanvasDeepResearchViewProps {
|
|
6
|
-
title?: string;
|
|
7
|
-
output_schema?: Record<string, any> | null;
|
|
8
|
-
content?: Record<string, any> | any[] | null;
|
|
9
|
-
basis?: any[] | null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function CanvasDeepResearchView({
|
|
13
|
-
title,
|
|
14
|
-
output_schema,
|
|
15
|
-
content,
|
|
16
|
-
basis
|
|
17
|
-
}: CanvasDeepResearchViewProps) {
|
|
18
|
-
return (
|
|
19
|
-
<div className="h-full w-full overflow-x-auto bg-muted">
|
|
20
|
-
<div className="max-w-7xl mx-auto p-6">
|
|
21
|
-
{title && (
|
|
22
|
-
<div className="mb-6">
|
|
23
|
-
<h2 className="text-2xl font-semibold text-gray-900">{title}</h2>
|
|
24
|
-
</div>
|
|
25
|
-
)}
|
|
26
|
-
|
|
27
|
-
{output_schema && content ? (
|
|
28
|
-
<div className="bg-white rounded-lg shadow-sm p-6">
|
|
29
|
-
<JsonSchemaLayout
|
|
30
|
-
schema={output_schema}
|
|
31
|
-
data={content}
|
|
32
|
-
basis={basis ?? []} />
|
|
33
|
-
</div>
|
|
34
|
-
) : (
|
|
35
|
-
<div className="bg-gray-50 border border-gray-200 rounded-lg p-8 text-center">
|
|
36
|
-
<p className="text-gray-500">No data available to display</p>
|
|
37
|
-
</div>
|
|
38
|
-
)}
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default CanvasDeepResearchView;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type FC } from 'react';
|
|
2
|
-
|
|
3
|
-
interface ImageData {
|
|
4
|
-
url: string;
|
|
5
|
-
width?: number;
|
|
6
|
-
height?: number;
|
|
7
|
-
mimeType?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface CanvasImageViewProps {
|
|
11
|
-
title?: string;
|
|
12
|
-
images?: ImageData[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const CanvasImageView: FC<CanvasImageViewProps> = ({ title = '', images = [] }) => (
|
|
16
|
-
<div className="h-full w-full overflow-x-hidden overflow-y-auto flex flex-col items-center space-y-2">
|
|
17
|
-
{images.map((image, index) => (
|
|
18
|
-
<img
|
|
19
|
-
key={index}
|
|
20
|
-
src={image.url}
|
|
21
|
-
alt={title || `Image ${index + 1}`}
|
|
22
|
-
className="w-fit max-w-full h-auto p-2 rounded" />
|
|
23
|
-
))}
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useCallback, useEffect, useState, type SyntheticEvent
|
|
5
|
-
} from 'react';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
AlertCircle, CheckCircle, Loader2
|
|
9
|
-
} from 'lucide-react';
|
|
10
|
-
|
|
11
|
-
import { Button } from '@docyrus/ui-pro-shared/components/button';
|
|
12
|
-
import { Input } from '@docyrus/ui-pro-shared/components/input';
|
|
13
|
-
import { Label } from '@docyrus/ui-pro-shared/components/label';
|
|
14
|
-
import { Separator } from '@docyrus/ui-pro-shared/components/separator';
|
|
15
|
-
|
|
16
|
-
import { useApiClient } from '../lib/api-client';
|
|
17
|
-
|
|
18
|
-
export type RecordMode = 'add' | 'edit' | 'view';
|
|
19
|
-
|
|
20
|
-
export interface CanvasRecordViewProps {
|
|
21
|
-
dataSourceId: string;
|
|
22
|
-
mode?: RecordMode;
|
|
23
|
-
defaultValues?: Record<string, any> | string;
|
|
24
|
-
recordId?: string;
|
|
25
|
-
onSave?: (id: string, data: Record<string, any>) => void;
|
|
26
|
-
onClose?: () => void;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface DsField {
|
|
30
|
-
id: string;
|
|
31
|
-
name: string;
|
|
32
|
-
slug: string;
|
|
33
|
-
type: string;
|
|
34
|
-
read_only?: boolean;
|
|
35
|
-
sort_order?: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface DsInfo {
|
|
39
|
-
id: string;
|
|
40
|
-
name: string;
|
|
41
|
-
slug: string;
|
|
42
|
-
app: { id: string; name: string; slug: string };
|
|
43
|
-
fields: DsField[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const parseValues = (values: any): Record<string, any> => {
|
|
47
|
-
if (!values) return {};
|
|
48
|
-
|
|
49
|
-
if (typeof values === 'string') {
|
|
50
|
-
try {
|
|
51
|
-
return JSON.parse(values);
|
|
52
|
-
} catch {
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return typeof values === 'object' ? values : {};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const isUuid = (str: string): boolean => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(str);
|
|
61
|
-
|
|
62
|
-
export function CanvasRecordView({
|
|
63
|
-
dataSourceId,
|
|
64
|
-
mode = 'add',
|
|
65
|
-
defaultValues,
|
|
66
|
-
recordId,
|
|
67
|
-
onSave,
|
|
68
|
-
onClose
|
|
69
|
-
}: CanvasRecordViewProps) {
|
|
70
|
-
const apiClient = useApiClient();
|
|
71
|
-
const parsedDefaults = parseValues(defaultValues);
|
|
72
|
-
|
|
73
|
-
// TODO: fetch dsInfo via config.getDataSourceSchema once auth strategy is finalized
|
|
74
|
-
const [dsInfo, _setDsInfo] = useState<DsInfo | null>(null);
|
|
75
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
76
|
-
const [formValues, setFormValues] = useState<Record<string, any>>(parsedDefaults);
|
|
77
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
78
|
-
const [error, setError] = useState<string | null>(null);
|
|
79
|
-
const [savedId, setSavedId] = useState<string | null>(null);
|
|
80
|
-
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
if (!dataSourceId) {
|
|
83
|
-
setIsLoading(false);
|
|
84
|
-
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let cancelled = false;
|
|
89
|
-
|
|
90
|
-
const init = async () => {
|
|
91
|
-
setIsLoading(true);
|
|
92
|
-
|
|
93
|
-
/*
|
|
94
|
-
* TODO: Fetch data source schema (fields + app slug) via getDataSourceSchema,
|
|
95
|
-
* then load record via REST if mode !== 'add'.
|
|
96
|
-
* Blocked by: auth strategy for server-side Supabase query.
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
if (!cancelled) {
|
|
100
|
-
setFormValues(parsedDefaults);
|
|
101
|
-
setIsLoading(false);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
init();
|
|
106
|
-
|
|
107
|
-
return () => {
|
|
108
|
-
cancelled = true;
|
|
109
|
-
};
|
|
110
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
-
}, [dataSourceId, mode, recordId]);
|
|
112
|
-
|
|
113
|
-
const handleChange = useCallback((key: string, val: any) => {
|
|
114
|
-
setFormValues(prev => ({
|
|
115
|
-
...prev,
|
|
116
|
-
[key]: val
|
|
117
|
-
}));
|
|
118
|
-
}, []);
|
|
119
|
-
|
|
120
|
-
const handleSubmit = async (e: SyntheticEvent<HTMLFormElement>) => {
|
|
121
|
-
e.preventDefault();
|
|
122
|
-
if (mode === 'view') return;
|
|
123
|
-
|
|
124
|
-
const appSlug = dsInfo?.app?.slug;
|
|
125
|
-
const dsSlug = dsInfo?.slug;
|
|
126
|
-
|
|
127
|
-
if (!appSlug || !dsSlug) {
|
|
128
|
-
setError('Data source information not loaded yet');
|
|
129
|
-
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
setIsSaving(true);
|
|
134
|
-
setError(null);
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
let res: any;
|
|
138
|
-
|
|
139
|
-
if (mode === 'add') {
|
|
140
|
-
res = await apiClient.post(`/apps/${appSlug}/data-sources/${dsSlug}/items`, formValues);
|
|
141
|
-
} else if (mode === 'edit' && recordId) {
|
|
142
|
-
res = await apiClient.patch(`/apps/${appSlug}/data-sources/${dsSlug}/items/${recordId}`, formValues);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (res?.success) {
|
|
146
|
-
const id = res.data?.id || recordId || '';
|
|
147
|
-
|
|
148
|
-
setSavedId(id);
|
|
149
|
-
onSave?.(id, res.data ?? formValues);
|
|
150
|
-
} else {
|
|
151
|
-
setError(res?.error || res?.message || 'Failed to save record');
|
|
152
|
-
}
|
|
153
|
-
} catch (err) {
|
|
154
|
-
setError(err instanceof Error ? err.message : 'Failed to save record');
|
|
155
|
-
} finally {
|
|
156
|
-
setIsSaving(false);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const renderFields = () => {
|
|
161
|
-
const fields = dsInfo?.fields
|
|
162
|
-
?.filter(f => !f.read_only || mode === 'view')
|
|
163
|
-
?.sort((a, b) => (a.sort_order ?? 0) - (b.sort_order ?? 0));
|
|
164
|
-
|
|
165
|
-
if (fields && fields.length > 0) {
|
|
166
|
-
return fields.map((field) => {
|
|
167
|
-
const value = formValues[field.slug] ?? formValues[field.id] ?? '';
|
|
168
|
-
const label = field.name || field.slug;
|
|
169
|
-
const readOnly = mode === 'view' || !!field.read_only;
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<div key={field.id} className="space-y-1.5">
|
|
173
|
-
<Label className="text-xs font-medium capitalize">{label}</Label>
|
|
174
|
-
{isUuid(String(value)) ? (
|
|
175
|
-
<div className="px-3 py-2 rounded-md border bg-muted/30 text-xs text-muted-foreground truncate">
|
|
176
|
-
{String(value)}
|
|
177
|
-
</div>
|
|
178
|
-
) : (
|
|
179
|
-
<Input
|
|
180
|
-
value={String(value)}
|
|
181
|
-
onChange={e => handleChange(field.slug, e.target.value)}
|
|
182
|
-
readOnly={readOnly}
|
|
183
|
-
className="text-sm h-9" />
|
|
184
|
-
)}
|
|
185
|
-
</div>
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Fallback: derive fields from formValues keys
|
|
191
|
-
return Object.entries(formValues).map(([key, value]) => {
|
|
192
|
-
if (key.endsWith('_currency')) return null;
|
|
193
|
-
|
|
194
|
-
const currencyKey = `${key}_currency`;
|
|
195
|
-
const currency = formValues[currencyKey];
|
|
196
|
-
const label = isUuid(key) ? `${key.slice(0, 8)}…` : key.replace(/_/g, ' ');
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<div key={key} className="space-y-1.5">
|
|
200
|
-
<Label className="text-xs font-medium capitalize">{label}</Label>
|
|
201
|
-
{isUuid(String(value)) ? (
|
|
202
|
-
<div className="px-3 py-2 rounded-md border bg-muted/30 text-xs text-muted-foreground truncate">
|
|
203
|
-
{String(value)}
|
|
204
|
-
</div>
|
|
205
|
-
) : (
|
|
206
|
-
<div className="flex gap-2">
|
|
207
|
-
<Input
|
|
208
|
-
value={String(value ?? '')}
|
|
209
|
-
onChange={e => handleChange(key, e.target.value)}
|
|
210
|
-
readOnly={mode === 'view'}
|
|
211
|
-
className="text-sm h-9" />
|
|
212
|
-
{currency && (
|
|
213
|
-
<div className="flex items-center px-2.5 bg-muted rounded-md text-xs font-medium shrink-0">
|
|
214
|
-
{String(currency)}
|
|
215
|
-
</div>
|
|
216
|
-
)}
|
|
217
|
-
</div>
|
|
218
|
-
)}
|
|
219
|
-
</div>
|
|
220
|
-
);
|
|
221
|
-
}).filter(Boolean);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const modeLabel = mode === 'add' ? 'Create' : mode === 'edit' ? 'Update' : 'View';
|
|
225
|
-
|
|
226
|
-
if (isLoading) {
|
|
227
|
-
return (
|
|
228
|
-
<div className="flex items-center justify-center h-full p-8">
|
|
229
|
-
<Loader2 className="size-5 animate-spin text-muted-foreground" />
|
|
230
|
-
</div>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (savedId !== null) {
|
|
235
|
-
return (
|
|
236
|
-
<div className="flex flex-col items-center justify-center h-full p-8 gap-4">
|
|
237
|
-
<CheckCircle className="size-10 text-green-500" />
|
|
238
|
-
<div className="text-center">
|
|
239
|
-
<div className="font-medium">Record saved successfully</div>
|
|
240
|
-
{savedId && <div className="text-xs text-muted-foreground mt-1">ID: {savedId}</div>}
|
|
241
|
-
</div>
|
|
242
|
-
<Button variant="outline" size="sm" onClick={onClose}>Close</Button>
|
|
243
|
-
</div>
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return (
|
|
248
|
-
<div className="flex flex-col h-full">
|
|
249
|
-
<form onSubmit={handleSubmit} className="flex flex-col flex-1 overflow-hidden">
|
|
250
|
-
<div className="flex-1 overflow-y-auto p-4 space-y-4">
|
|
251
|
-
{error && (
|
|
252
|
-
<div className="flex items-start gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-md text-destructive text-sm">
|
|
253
|
-
<AlertCircle className="size-4 mt-0.5 shrink-0" />
|
|
254
|
-
<span>{error}</span>
|
|
255
|
-
</div>
|
|
256
|
-
)}
|
|
257
|
-
|
|
258
|
-
{renderFields()}
|
|
259
|
-
|
|
260
|
-
{Object.keys(formValues).length === 0 && !dsInfo?.fields?.length && (
|
|
261
|
-
<div className="text-sm text-muted-foreground text-center py-8">
|
|
262
|
-
No fields available for this data source
|
|
263
|
-
</div>
|
|
264
|
-
)}
|
|
265
|
-
</div>
|
|
266
|
-
|
|
267
|
-
{mode !== 'view' && (
|
|
268
|
-
<>
|
|
269
|
-
<Separator />
|
|
270
|
-
<div className="flex items-center justify-end gap-2 p-4 shrink-0">
|
|
271
|
-
{onClose && (
|
|
272
|
-
<Button type="button" variant="outline" size="sm" onClick={onClose}>
|
|
273
|
-
Cancel
|
|
274
|
-
</Button>
|
|
275
|
-
)}
|
|
276
|
-
<Button type="submit" size="sm" disabled={isSaving}>
|
|
277
|
-
{isSaving ? <><Loader2 className="size-3.5 mr-1.5 animate-spin" />Saving…</> : `${modeLabel} Record`}
|
|
278
|
-
</Button>
|
|
279
|
-
</div>
|
|
280
|
-
</>
|
|
281
|
-
)}
|
|
282
|
-
</form>
|
|
283
|
-
</div>
|
|
284
|
-
);
|
|
285
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
import { UniverSheets } from '../internal/sheets';
|
|
6
|
-
|
|
7
|
-
interface CanvasSpreadsheetViewProps {
|
|
8
|
-
title?: string;
|
|
9
|
-
content?: Record<string, any> | null;
|
|
10
|
-
workId?: string;
|
|
11
|
-
versionId?: string;
|
|
12
|
-
commands?: any[];
|
|
13
|
-
onData?: (data: { workbook: unknown; workbookJson: string }) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const toSparse = (arr: any): Record<string, any> => {
|
|
17
|
-
if (!Array.isArray(arr)) {
|
|
18
|
-
return arr || {};
|
|
19
|
-
}
|
|
20
|
-
const m: Record<string, any> = {};
|
|
21
|
-
|
|
22
|
-
arr.forEach((row: any, r: number) => row?.forEach((cell: any, c: number) => cell && ((m[r] = m[r] || {})[c] = cell)));
|
|
23
|
-
|
|
24
|
-
return m;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const transformSheet = (sheet: Record<string, any>, sheetId: string) => {
|
|
28
|
-
const keys = [
|
|
29
|
-
'id',
|
|
30
|
-
'name',
|
|
31
|
-
'columnCount',
|
|
32
|
-
'rowCount',
|
|
33
|
-
'mergeData',
|
|
34
|
-
'rowData',
|
|
35
|
-
'columnData',
|
|
36
|
-
'rowHeader',
|
|
37
|
-
'columnHeader',
|
|
38
|
-
'showGridlines',
|
|
39
|
-
'rightToLeft',
|
|
40
|
-
'freeze',
|
|
41
|
-
'defaultColumnWidth',
|
|
42
|
-
'defaultRowHeight',
|
|
43
|
-
'tabColor',
|
|
44
|
-
'hidden'
|
|
45
|
-
];
|
|
46
|
-
const result: Record<string, any> = { cellData: toSparse(sheet.cellData), id: sheetId };
|
|
47
|
-
|
|
48
|
-
keys.forEach(k => sheet[k] != null && (result[k] = sheet[k]));
|
|
49
|
-
|
|
50
|
-
return result;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const transformWorkbook = (wb: Record<string, any> | null | undefined): Record<string, any> | null => {
|
|
54
|
-
if (!wb) return null;
|
|
55
|
-
|
|
56
|
-
const sheetsObject: Record<string, any> = {};
|
|
57
|
-
|
|
58
|
-
const rawSheets = Array.isArray(wb.sheets) ? wb.sheets : Object.values(wb.sheets ?? {});
|
|
59
|
-
|
|
60
|
-
rawSheets.forEach((s: any, index: number) => {
|
|
61
|
-
if (!s || s === '') return;
|
|
62
|
-
|
|
63
|
-
let sheetData: Record<string, any>;
|
|
64
|
-
|
|
65
|
-
if (typeof s === 'string') {
|
|
66
|
-
try {
|
|
67
|
-
sheetData = JSON.parse(s);
|
|
68
|
-
} catch {
|
|
69
|
-
console.warn(`Sheet at index ${index} is not valid JSON:`, s);
|
|
70
|
-
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
sheetData = s;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (sheetData?.id && sheetData?.sheet) {
|
|
78
|
-
sheetsObject[sheetData.id] = transformSheet(sheetData.sheet, sheetData.id);
|
|
79
|
-
} else if (sheetData?.id) {
|
|
80
|
-
sheetsObject[sheetData.id] = transformSheet(sheetData, sheetData.id);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const validSheetIds = new Set(Object.keys(sheetsObject));
|
|
85
|
-
const sheetOrder = (wb.sheetOrder || []).filter((id: string) => validSheetIds.has(id));
|
|
86
|
-
|
|
87
|
-
const workbookData: Record<string, any> = {
|
|
88
|
-
id: wb.id,
|
|
89
|
-
name: wb.name,
|
|
90
|
-
sheetOrder,
|
|
91
|
-
sheets: sheetsObject
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
if (wb.styles) {
|
|
95
|
-
if (Array.isArray(wb.styles)) {
|
|
96
|
-
workbookData.styles = {};
|
|
97
|
-
wb.styles.forEach((s: any) => {
|
|
98
|
-
if (s.id && s.style) {
|
|
99
|
-
workbookData.styles[s.id] = s.style;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
workbookData.styles = wb.styles;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return workbookData;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export function CanvasSpreadsheetView({
|
|
111
|
-
content,
|
|
112
|
-
commands,
|
|
113
|
-
onData
|
|
114
|
-
}: CanvasSpreadsheetViewProps) {
|
|
115
|
-
const workbookData = useMemo(() => transformWorkbook(content?.workbook ?? content), [content]);
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<div className="h-full w-full overflow-hidden bg-muted flex relative">
|
|
119
|
-
<UniverSheets
|
|
120
|
-
initialData={workbookData ?? undefined}
|
|
121
|
-
commands={commands}
|
|
122
|
-
onData={onData} />
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PlateEditor, type PlateEditorHandle } from '../internal/plate-editor';
|
|
4
|
-
|
|
5
|
-
import { useAssistantConfig } from '../lib/assistant-config';
|
|
6
|
-
import { CanvasCodeView } from './canvas-code';
|
|
7
|
-
|
|
8
|
-
type TextLanguage = 'markdown' | 'plain_text' | 'json' | 'javascript' | 'typescript' | 'html' | 'sql';
|
|
9
|
-
|
|
10
|
-
interface CanvasTextViewProps {
|
|
11
|
-
contentText?: string;
|
|
12
|
-
language?: TextLanguage;
|
|
13
|
-
title?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function MarkdownView({ contentText = '' }: { contentText?: string }) {
|
|
17
|
-
const editorRef = useRef<PlateEditorHandle>(null);
|
|
18
|
-
const { getAuthToken } = useAssistantConfig();
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
editorRef.current?.setMarkdown(contentText);
|
|
22
|
-
}, [contentText]);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<PlateEditor
|
|
26
|
-
ref={editorRef}
|
|
27
|
-
getAccessToken={getAuthToken}
|
|
28
|
-
onReady={() => editorRef.current?.setMarkdown(contentText)} />
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function CanvasTextView({
|
|
33
|
-
contentText = '',
|
|
34
|
-
language = 'markdown',
|
|
35
|
-
title = ''
|
|
36
|
-
}: CanvasTextViewProps) {
|
|
37
|
-
if (language === 'markdown' || language === 'plain_text') {
|
|
38
|
-
return (
|
|
39
|
-
<div className="h-full w-full overflow-x-auto bg-muted flex justify-center items-start">
|
|
40
|
-
<MarkdownView contentText={contentText} />
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div className="h-full w-full overflow-x-auto">
|
|
47
|
-
<CanvasCodeView contentText={contentText} language={language} title={title} />
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default CanvasTextView;
|