@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
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useCallback, useEffect, useRef, useState, type ChangeEvent, type ReactNode, type RefObject
|
|
5
|
+
} from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
PlaceholderPlugin,
|
|
9
|
+
PlaceholderProvider,
|
|
10
|
+
usePlaceholderElementState,
|
|
11
|
+
usePlaceholderPopoverState
|
|
12
|
+
} from '@platejs/media/react';
|
|
13
|
+
import {
|
|
14
|
+
AudioLinesIcon, FileUpIcon, FilmIcon, ImageIcon
|
|
15
|
+
} from 'lucide-react';
|
|
16
|
+
import { KEYS, nanoid } from 'platejs';
|
|
17
|
+
import {
|
|
18
|
+
PlateElement,
|
|
19
|
+
type PlateElementProps,
|
|
20
|
+
useEditorPlugin,
|
|
21
|
+
withHOC
|
|
22
|
+
} from 'platejs/react';
|
|
23
|
+
|
|
24
|
+
import { setMediaNode } from '@platejs/media';
|
|
25
|
+
|
|
26
|
+
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
27
|
+
|
|
28
|
+
import { BlockActionButton } from './block-context-menu';
|
|
29
|
+
import { Button } from './button';
|
|
30
|
+
import { Input } from './input';
|
|
31
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover';
|
|
32
|
+
import { Spinner } from './spinner';
|
|
33
|
+
import {
|
|
34
|
+
Tabs, TabsContent, TabsList, TabsTrigger
|
|
35
|
+
} from './tabs';
|
|
36
|
+
|
|
37
|
+
import { useUploadFile } from '../hooks/use-upload-file';
|
|
38
|
+
|
|
39
|
+
const CONTENT: Record<
|
|
40
|
+
string,
|
|
41
|
+
{
|
|
42
|
+
content: ReactNode;
|
|
43
|
+
icon: ReactNode;
|
|
44
|
+
}
|
|
45
|
+
> = {
|
|
46
|
+
[KEYS.audio]: {
|
|
47
|
+
content: 'Add an audio file',
|
|
48
|
+
icon: <AudioLinesIcon />
|
|
49
|
+
},
|
|
50
|
+
[KEYS.file]: {
|
|
51
|
+
content: 'Add a file',
|
|
52
|
+
icon: <FileUpIcon />
|
|
53
|
+
},
|
|
54
|
+
[KEYS.img]: {
|
|
55
|
+
content: 'Add an image',
|
|
56
|
+
icon: <ImageIcon />
|
|
57
|
+
},
|
|
58
|
+
[KEYS.video]: {
|
|
59
|
+
content: 'Add a video',
|
|
60
|
+
icon: <FilmIcon />
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const PlaceholderElement = withHOC(
|
|
65
|
+
PlaceholderProvider,
|
|
66
|
+
(props: PlateElementProps) => {
|
|
67
|
+
const {
|
|
68
|
+
mediaType, progresses, progressing, setSize, updatedFiles
|
|
69
|
+
}
|
|
70
|
+
= usePlaceholderElementState();
|
|
71
|
+
|
|
72
|
+
const currentContent = CONTENT[mediaType];
|
|
73
|
+
|
|
74
|
+
const isImage = mediaType === KEYS.img;
|
|
75
|
+
|
|
76
|
+
const file: File | undefined = updatedFiles?.[0];
|
|
77
|
+
const progress = file ? progresses?.[file.name] : undefined;
|
|
78
|
+
|
|
79
|
+
const imageRef = useRef<HTMLImageElement>(null);
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!imageRef.current) return;
|
|
83
|
+
|
|
84
|
+
const { height, width } = imageRef.current;
|
|
85
|
+
|
|
86
|
+
setSize?.({
|
|
87
|
+
height,
|
|
88
|
+
width
|
|
89
|
+
});
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
}, [imageRef.current]);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<PlateElement className="my-1" {...props}>
|
|
95
|
+
<MediaPlaceholderPopover>
|
|
96
|
+
{(!progressing || !isImage) && (
|
|
97
|
+
<div
|
|
98
|
+
className={cn(
|
|
99
|
+
'flex cursor-pointer select-none items-center rounded-sm bg-muted p-3 pr-9 transition-bg-ease hover:bg-primary/10'
|
|
100
|
+
)}
|
|
101
|
+
contentEditable={false}
|
|
102
|
+
role="button">
|
|
103
|
+
<div className="relative mr-3 flex text-muted-foreground/80 [&_svg]:size-6">
|
|
104
|
+
{currentContent.icon}
|
|
105
|
+
</div>
|
|
106
|
+
<div className="whitespace-nowrap text-muted-foreground text-sm">
|
|
107
|
+
<div>{progressing ? file?.name : currentContent.content}</div>
|
|
108
|
+
|
|
109
|
+
{progressing && !isImage && (
|
|
110
|
+
<div className="mt-1 flex items-center gap-1.5">
|
|
111
|
+
<div>{formatBytes(file.size)}</div>
|
|
112
|
+
<div>-</div>
|
|
113
|
+
<div className="flex items-center">
|
|
114
|
+
<Spinner className="mr-1 size-3.5" />
|
|
115
|
+
{progress ?? 0}%
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
</MediaPlaceholderPopover>
|
|
123
|
+
|
|
124
|
+
{isImage && progressing && file && (
|
|
125
|
+
<ImageProgress file={file} imageRef={imageRef} progress={progress} />
|
|
126
|
+
)}
|
|
127
|
+
|
|
128
|
+
<BlockActionButton />
|
|
129
|
+
|
|
130
|
+
{props.children}
|
|
131
|
+
</PlateElement>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const MEDIA_CONFIG: Record<
|
|
137
|
+
string,
|
|
138
|
+
{
|
|
139
|
+
accept: string[];
|
|
140
|
+
buttonText: string;
|
|
141
|
+
embedText: string;
|
|
142
|
+
}
|
|
143
|
+
> = {
|
|
144
|
+
[KEYS.audio]: {
|
|
145
|
+
accept: ['audio/*'],
|
|
146
|
+
buttonText: 'Upload Audio',
|
|
147
|
+
embedText: 'Embed audio'
|
|
148
|
+
},
|
|
149
|
+
[KEYS.file]: {
|
|
150
|
+
accept: ['*'],
|
|
151
|
+
buttonText: 'Choose a file',
|
|
152
|
+
embedText: 'Embed file'
|
|
153
|
+
},
|
|
154
|
+
[KEYS.img]: {
|
|
155
|
+
accept: ['image/*'],
|
|
156
|
+
buttonText: 'Upload file',
|
|
157
|
+
embedText: 'Embed image'
|
|
158
|
+
},
|
|
159
|
+
[KEYS.video]: {
|
|
160
|
+
accept: ['video/*'],
|
|
161
|
+
buttonText: 'Upload video',
|
|
162
|
+
embedText: 'Embed video'
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
function MediaPlaceholderPopover({ children }: { children: ReactNode }) {
|
|
167
|
+
const {
|
|
168
|
+
api, editor, getOption, tf
|
|
169
|
+
} = useEditorPlugin(PlaceholderPlugin);
|
|
170
|
+
|
|
171
|
+
const {
|
|
172
|
+
id,
|
|
173
|
+
element,
|
|
174
|
+
mediaType,
|
|
175
|
+
readOnly,
|
|
176
|
+
selected,
|
|
177
|
+
setIsUploading,
|
|
178
|
+
setProgresses,
|
|
179
|
+
setUpdatedFiles,
|
|
180
|
+
size
|
|
181
|
+
} = usePlaceholderPopoverState();
|
|
182
|
+
const [open, setOpen] = useState(false);
|
|
183
|
+
|
|
184
|
+
const currentMedia = MEDIA_CONFIG[mediaType];
|
|
185
|
+
|
|
186
|
+
const multiple = getOption('multiple') ?? true;
|
|
187
|
+
|
|
188
|
+
const {
|
|
189
|
+
isUploading, progress, uploadedFile, uploadFile, uploadingFile
|
|
190
|
+
}
|
|
191
|
+
= useUploadFile({
|
|
192
|
+
onUploadComplete() {
|
|
193
|
+
// Replace with actual file creation logic
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const replaceCurrentPlaceholder = useCallback(
|
|
198
|
+
(file: File) => {
|
|
199
|
+
setUpdatedFiles([file]);
|
|
200
|
+
void uploadFile(file);
|
|
201
|
+
api.placeholder.addUploadingFile(element.id as string, file);
|
|
202
|
+
},
|
|
203
|
+
[
|
|
204
|
+
element.id,
|
|
205
|
+
setUpdatedFiles,
|
|
206
|
+
uploadFile,
|
|
207
|
+
api.placeholder
|
|
208
|
+
]
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
/** Open file picker using native input */
|
|
212
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
213
|
+
|
|
214
|
+
const openFilePicker = useCallback(() => {
|
|
215
|
+
if (fileInputRef.current) {
|
|
216
|
+
fileInputRef.current.value = '';
|
|
217
|
+
fileInputRef.current.click();
|
|
218
|
+
}
|
|
219
|
+
}, []);
|
|
220
|
+
|
|
221
|
+
const handleFilesSelected = useCallback(
|
|
222
|
+
(e: ChangeEvent<HTMLInputElement>) => {
|
|
223
|
+
const updatedFiles: File[] = Array.from(e.target.files || []);
|
|
224
|
+
|
|
225
|
+
if (!updatedFiles.length) return;
|
|
226
|
+
|
|
227
|
+
const firstFile = updatedFiles[0];
|
|
228
|
+
const restFiles = updatedFiles.slice(1);
|
|
229
|
+
|
|
230
|
+
replaceCurrentPlaceholder(firstFile);
|
|
231
|
+
|
|
232
|
+
if (restFiles.length > 0) {
|
|
233
|
+
tf.insert.media(restFiles as unknown as FileList);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
[replaceCurrentPlaceholder, tf.insert]
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
// React dev mode will call useEffect twice
|
|
240
|
+
const isReplaced = useRef(false);
|
|
241
|
+
|
|
242
|
+
/** Paste and drop */
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
if (isReplaced.current) return;
|
|
245
|
+
|
|
246
|
+
isReplaced.current = true;
|
|
247
|
+
const currentFiles = api.placeholder.getUploadingFile(element.id as string);
|
|
248
|
+
|
|
249
|
+
if (!currentFiles) return;
|
|
250
|
+
|
|
251
|
+
replaceCurrentPlaceholder(currentFiles);
|
|
252
|
+
|
|
253
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
254
|
+
}, [isReplaced]);
|
|
255
|
+
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (!uploadedFile) return;
|
|
258
|
+
|
|
259
|
+
const path = editor.api.findPath(element);
|
|
260
|
+
|
|
261
|
+
setMediaNode(
|
|
262
|
+
editor,
|
|
263
|
+
{
|
|
264
|
+
id: nanoid(),
|
|
265
|
+
initialHeight: size?.height,
|
|
266
|
+
initialWidth: size?.width,
|
|
267
|
+
isUpload: true,
|
|
268
|
+
name: mediaType === KEYS.file ? uploadedFile.name : '',
|
|
269
|
+
placeholderId: element.id as string,
|
|
270
|
+
type: mediaType!,
|
|
271
|
+
url: uploadedFile.url
|
|
272
|
+
},
|
|
273
|
+
{ at: path }
|
|
274
|
+
);
|
|
275
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
276
|
+
}, [uploadedFile, element.id, size]);
|
|
277
|
+
|
|
278
|
+
const [embedValue, setEmbedValue] = useState('');
|
|
279
|
+
|
|
280
|
+
const onEmbed = useCallback(
|
|
281
|
+
(value: string) => {
|
|
282
|
+
setMediaNode(editor, {
|
|
283
|
+
type: mediaType,
|
|
284
|
+
url: value
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
[editor, mediaType]
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
setOpen(selected);
|
|
292
|
+
}, [selected, setOpen]);
|
|
293
|
+
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
if (isUploading) {
|
|
296
|
+
setOpen(false);
|
|
297
|
+
}
|
|
298
|
+
}, [isUploading]);
|
|
299
|
+
|
|
300
|
+
useEffect(() => {
|
|
301
|
+
setProgresses({ [uploadingFile?.name ?? '']: progress });
|
|
302
|
+
setIsUploading(isUploading);
|
|
303
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
304
|
+
}, [
|
|
305
|
+
id,
|
|
306
|
+
progress,
|
|
307
|
+
isUploading,
|
|
308
|
+
uploadingFile
|
|
309
|
+
]);
|
|
310
|
+
|
|
311
|
+
if (readOnly) return <>{children}</>;
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<Popover modal={false} onOpenChange={setOpen} open={open}>
|
|
315
|
+
<input
|
|
316
|
+
ref={fileInputRef}
|
|
317
|
+
type="file"
|
|
318
|
+
accept={currentMedia.accept.join(',')}
|
|
319
|
+
multiple={multiple}
|
|
320
|
+
onChange={handleFilesSelected}
|
|
321
|
+
className="hidden" />
|
|
322
|
+
<PopoverTrigger asChild>{children}</PopoverTrigger>
|
|
323
|
+
|
|
324
|
+
<PopoverContent
|
|
325
|
+
className="flex flex-col"
|
|
326
|
+
onOpenAutoFocus={e => e.preventDefault()}
|
|
327
|
+
variant="media">
|
|
328
|
+
<Tabs className="w-full shrink-0" defaultValue="account">
|
|
329
|
+
<TabsList className="px-2" onMouseDown={e => e.preventDefault()}>
|
|
330
|
+
<TabsTrigger value="account">Upload</TabsTrigger>
|
|
331
|
+
<TabsTrigger value="password">Embed link</TabsTrigger>
|
|
332
|
+
</TabsList>
|
|
333
|
+
<TabsContent className="w-[300px] px-3 py-2" value="account">
|
|
334
|
+
<Button className="w-full" onClick={openFilePicker} variant="brand">
|
|
335
|
+
{currentMedia.buttonText}
|
|
336
|
+
</Button>
|
|
337
|
+
<div className="mt-3 text-muted-foreground text-xs">
|
|
338
|
+
The maximum size per file is 5MB
|
|
339
|
+
</div>
|
|
340
|
+
</TabsContent>
|
|
341
|
+
|
|
342
|
+
<TabsContent
|
|
343
|
+
className="w-[300px] px-3 pt-2 pb-3 text-center"
|
|
344
|
+
value="password">
|
|
345
|
+
<Input
|
|
346
|
+
onChange={e => setEmbedValue(e.target.value)}
|
|
347
|
+
placeholder="Paste the link..."
|
|
348
|
+
value={embedValue} />
|
|
349
|
+
|
|
350
|
+
<Button
|
|
351
|
+
className="mt-2 w-full max-w-[300px]"
|
|
352
|
+
onClick={() => onEmbed(embedValue)}
|
|
353
|
+
variant="brand">
|
|
354
|
+
{currentMedia.embedText}
|
|
355
|
+
</Button>
|
|
356
|
+
</TabsContent>
|
|
357
|
+
</Tabs>
|
|
358
|
+
</PopoverContent>
|
|
359
|
+
</Popover>
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function ImageProgress({
|
|
364
|
+
className,
|
|
365
|
+
file,
|
|
366
|
+
imageRef,
|
|
367
|
+
progress = 0
|
|
368
|
+
}: {
|
|
369
|
+
file: File;
|
|
370
|
+
className?: string;
|
|
371
|
+
imageRef?: RefObject<HTMLImageElement | null>;
|
|
372
|
+
progress?: number;
|
|
373
|
+
}) {
|
|
374
|
+
const [objectUrl, setObjectUrl] = useState<string | null>(null);
|
|
375
|
+
|
|
376
|
+
// Create and manage Object URL lifecycle
|
|
377
|
+
useEffect(() => {
|
|
378
|
+
const url = URL.createObjectURL(file);
|
|
379
|
+
|
|
380
|
+
setObjectUrl(url);
|
|
381
|
+
|
|
382
|
+
return () => {
|
|
383
|
+
URL.revokeObjectURL(url);
|
|
384
|
+
};
|
|
385
|
+
}, [file]);
|
|
386
|
+
|
|
387
|
+
if (!objectUrl) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return (
|
|
392
|
+
<div className={cn('relative', className)} contentEditable={false}>
|
|
393
|
+
<img
|
|
394
|
+
alt={file.name}
|
|
395
|
+
className="h-auto w-full rounded-xs object-cover"
|
|
396
|
+
ref={imageRef}
|
|
397
|
+
src={objectUrl} />
|
|
398
|
+
{progress < 100 && (
|
|
399
|
+
<div className="absolute right-1 bottom-1 flex items-center space-x-2 rounded-full bg-black/50 px-1 py-0.5">
|
|
400
|
+
<Spinner />
|
|
401
|
+
<span className="font-medium text-white text-xs">
|
|
402
|
+
{Math.round(progress)}%
|
|
403
|
+
</span>
|
|
404
|
+
</div>
|
|
405
|
+
)}
|
|
406
|
+
</div>
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function formatBytes(
|
|
411
|
+
bytes: number,
|
|
412
|
+
opts: {
|
|
413
|
+
decimals?: number;
|
|
414
|
+
sizeType?: 'accurate' | 'normal';
|
|
415
|
+
} = {}
|
|
416
|
+
) {
|
|
417
|
+
const { decimals = 0, sizeType = 'normal' } = opts;
|
|
418
|
+
|
|
419
|
+
const sizes = [
|
|
420
|
+
'Bytes',
|
|
421
|
+
'KB',
|
|
422
|
+
'MB',
|
|
423
|
+
'GB',
|
|
424
|
+
'TB'
|
|
425
|
+
];
|
|
426
|
+
const accurateSizes = [
|
|
427
|
+
'Bytes',
|
|
428
|
+
'KiB',
|
|
429
|
+
'MiB',
|
|
430
|
+
'GiB',
|
|
431
|
+
'TiB'
|
|
432
|
+
];
|
|
433
|
+
|
|
434
|
+
if (bytes === 0) return '0 Byte';
|
|
435
|
+
|
|
436
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
437
|
+
|
|
438
|
+
return `${(bytes / 1024 ** i).toFixed(decimals)} ${
|
|
439
|
+
sizeType === 'accurate' ? (accurateSizes[i] ?? 'Bytest') : (sizes[i] ?? 'Bytes')
|
|
440
|
+
}`;
|
|
441
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { type ComponentProps } from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
PreviewImage,
|
|
7
|
+
useImagePreview,
|
|
8
|
+
useImagePreviewValue,
|
|
9
|
+
useScaleInput
|
|
10
|
+
} from '@platejs/media/react';
|
|
11
|
+
import {
|
|
12
|
+
ArrowLeftIcon,
|
|
13
|
+
ArrowRightIcon,
|
|
14
|
+
CircleArrowDown,
|
|
15
|
+
Minimize2,
|
|
16
|
+
Minus,
|
|
17
|
+
Plus
|
|
18
|
+
} from 'lucide-react';
|
|
19
|
+
import { useEditorRef } from 'platejs/react';
|
|
20
|
+
|
|
21
|
+
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
22
|
+
|
|
23
|
+
import { Button } from './button';
|
|
24
|
+
|
|
25
|
+
import { downloadFile } from '../lib/download-file';
|
|
26
|
+
|
|
27
|
+
const SCROLL_SPEED = 4;
|
|
28
|
+
|
|
29
|
+
export function ImagePreview() {
|
|
30
|
+
const editor = useEditorRef();
|
|
31
|
+
const isOpen = useImagePreviewValue('isOpen', editor.id);
|
|
32
|
+
const scale = useImagePreviewValue('scale');
|
|
33
|
+
const isEditingScale = useImagePreviewValue('isEditingScale');
|
|
34
|
+
const currentPreview = useImagePreviewValue('currentPreview');
|
|
35
|
+
const {
|
|
36
|
+
closeProps,
|
|
37
|
+
maskLayerProps,
|
|
38
|
+
nextDisabled,
|
|
39
|
+
nextProps,
|
|
40
|
+
prevDisabled,
|
|
41
|
+
prevProps,
|
|
42
|
+
scaleTextProps,
|
|
43
|
+
zommOutProps,
|
|
44
|
+
zoomInDisabled,
|
|
45
|
+
zoomInProps,
|
|
46
|
+
zoomOutDisabled
|
|
47
|
+
} = useImagePreview({
|
|
48
|
+
scrollSpeed: SCROLL_SPEED
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
className={cn(
|
|
54
|
+
'fade-in fixed top-0 left-0 z-50 h-screen w-screen animate-in cursor-default text-sm duration-200 ease-in-out',
|
|
55
|
+
!isOpen && 'hidden'
|
|
56
|
+
)}
|
|
57
|
+
onContextMenu={e => e.stopPropagation()}
|
|
58
|
+
{...maskLayerProps}>
|
|
59
|
+
<div className="absolute inset-0 size-full bg-black/80" />
|
|
60
|
+
|
|
61
|
+
<div className="absolute inset-0 flex items-center justify-center">
|
|
62
|
+
<div className="relative flex max-h-screen w-full items-center">
|
|
63
|
+
<PreviewImage
|
|
64
|
+
className={cn(
|
|
65
|
+
'mx-auto block max-h-[calc(100vh-4rem)] w-auto select-none object-contain transition-transform'
|
|
66
|
+
)} />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div
|
|
71
|
+
className="-translate-x-1/2 absolute bottom-[30px] left-1/2 z-40 flex justify-center gap-2 text-white"
|
|
72
|
+
onClick={e => e.stopPropagation()}>
|
|
73
|
+
{!prevDisabled && !nextDisabled && (
|
|
74
|
+
<div className="flex rounded-sm bg-black/70">
|
|
75
|
+
<Button {...prevProps} disabled={prevDisabled}>
|
|
76
|
+
<ArrowLeftIcon className="size-5" />
|
|
77
|
+
</Button>
|
|
78
|
+
<Button {...nextProps} disabled={nextDisabled}>
|
|
79
|
+
<ArrowRightIcon className="size-5" />
|
|
80
|
+
</Button>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
{currentPreview && (
|
|
85
|
+
<div className="flex rounded-sm bg-black/70">
|
|
86
|
+
<Button
|
|
87
|
+
{...zommOutProps}
|
|
88
|
+
disabled={zoomOutDisabled}
|
|
89
|
+
tooltip="Zoom out">
|
|
90
|
+
<Minus className="size-4" />
|
|
91
|
+
</Button>
|
|
92
|
+
<div className="flex w-[46px] items-center justify-center space-x-1 text-neutral-400">
|
|
93
|
+
{isEditingScale ? (
|
|
94
|
+
<ScaleInput className="h-[19px] w-full rounded-sm border border-brand/70 bg-transparent text-sm text-white outline-hidden" />
|
|
95
|
+
) : (
|
|
96
|
+
<div {...scaleTextProps}>{scale * 100}</div>
|
|
97
|
+
)}
|
|
98
|
+
<div>%</div>
|
|
99
|
+
</div>
|
|
100
|
+
<Button
|
|
101
|
+
{...zoomInProps}
|
|
102
|
+
disabled={zoomInDisabled}
|
|
103
|
+
tooltip="Zoom in">
|
|
104
|
+
<Plus className="size-4" />
|
|
105
|
+
</Button>
|
|
106
|
+
<Button
|
|
107
|
+
onClick={() => {
|
|
108
|
+
void downloadFile(currentPreview.url, currentPreview.id!);
|
|
109
|
+
}}
|
|
110
|
+
tooltip="Download">
|
|
111
|
+
<CircleArrowDown className="size-4" />
|
|
112
|
+
</Button>
|
|
113
|
+
<Button {...closeProps} tooltip="Close">
|
|
114
|
+
<Minimize2 className="size-4" />
|
|
115
|
+
</Button>
|
|
116
|
+
</div>
|
|
117
|
+
)}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function ScaleInput(props: ComponentProps<'input'>) {
|
|
124
|
+
const { props: scaleInputProps, ref } = useScaleInput();
|
|
125
|
+
|
|
126
|
+
return <input {...scaleInputProps} {...props} ref={ref} />;
|
|
127
|
+
}
|