@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.3
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/package.json +2 -3
- 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,127 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useCallback, useState, type ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import { PlaceholderPlugin } from '@platejs/media/react';
|
|
6
|
-
import {
|
|
7
|
-
AudioLinesIcon,
|
|
8
|
-
FileUpIcon,
|
|
9
|
-
FilmIcon,
|
|
10
|
-
ImageIcon,
|
|
11
|
-
LinkIcon
|
|
12
|
-
} from 'lucide-react';
|
|
13
|
-
import { isUrl, KEYS } from 'platejs';
|
|
14
|
-
import { useEditorRef } from 'platejs/react';
|
|
15
|
-
import { toast } from 'sonner';
|
|
16
|
-
import { useFilePicker } from 'use-file-picker';
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
AlertDialog,
|
|
20
|
-
AlertDialogAction,
|
|
21
|
-
AlertDialogCancel,
|
|
22
|
-
AlertDialogContent,
|
|
23
|
-
AlertDialogDescription,
|
|
24
|
-
AlertDialogFooter,
|
|
25
|
-
AlertDialogHeader,
|
|
26
|
-
AlertDialogTitle
|
|
27
|
-
} from './alert-dialog';
|
|
28
|
-
import {
|
|
29
|
-
DropdownMenu,
|
|
30
|
-
DropdownMenuContent,
|
|
31
|
-
DropdownMenuGroup,
|
|
32
|
-
DropdownMenuItem,
|
|
33
|
-
DropdownMenuPortal,
|
|
34
|
-
DropdownMenuTrigger,
|
|
35
|
-
type DropdownMenuProps
|
|
36
|
-
} from './dropdown-menu';
|
|
37
|
-
import { Input } from './input';
|
|
38
|
-
|
|
39
|
-
import {
|
|
40
|
-
ToolbarSplitButton,
|
|
41
|
-
ToolbarSplitButtonPrimary,
|
|
42
|
-
ToolbarSplitButtonSecondary
|
|
43
|
-
} from './toolbar';
|
|
44
|
-
|
|
45
|
-
const MEDIA_CONFIG: Record<
|
|
46
|
-
string,
|
|
47
|
-
{
|
|
48
|
-
accept: string[];
|
|
49
|
-
icon: ReactNode;
|
|
50
|
-
title: string;
|
|
51
|
-
tooltip: string;
|
|
52
|
-
}
|
|
53
|
-
> = {
|
|
54
|
-
[KEYS.audio]: {
|
|
55
|
-
accept: ['audio/*'],
|
|
56
|
-
icon: <AudioLinesIcon className="size-4" />,
|
|
57
|
-
title: 'Insert Audio',
|
|
58
|
-
tooltip: 'Audio'
|
|
59
|
-
},
|
|
60
|
-
[KEYS.file]: {
|
|
61
|
-
accept: ['*'],
|
|
62
|
-
icon: <FileUpIcon className="size-4" />,
|
|
63
|
-
title: 'Insert File',
|
|
64
|
-
tooltip: 'File'
|
|
65
|
-
},
|
|
66
|
-
[KEYS.img]: {
|
|
67
|
-
accept: ['image/*'],
|
|
68
|
-
icon: <ImageIcon className="size-4" />,
|
|
69
|
-
title: 'Insert Image',
|
|
70
|
-
tooltip: 'Image'
|
|
71
|
-
},
|
|
72
|
-
[KEYS.video]: {
|
|
73
|
-
accept: ['video/*'],
|
|
74
|
-
icon: <FilmIcon className="size-4" />,
|
|
75
|
-
title: 'Insert Video',
|
|
76
|
-
tooltip: 'Video'
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export function MediaToolbarButton({
|
|
81
|
-
nodeType,
|
|
82
|
-
...props
|
|
83
|
-
}: DropdownMenuProps & { nodeType: string }) {
|
|
84
|
-
const currentConfig = MEDIA_CONFIG[nodeType];
|
|
85
|
-
|
|
86
|
-
const editor = useEditorRef();
|
|
87
|
-
const [open, setOpen] = useState(false);
|
|
88
|
-
const [dialogOpen, setDialogOpen] = useState(false);
|
|
89
|
-
|
|
90
|
-
const { openFilePicker } = useFilePicker({
|
|
91
|
-
accept: currentConfig.accept,
|
|
92
|
-
multiple: true,
|
|
93
|
-
onFilesSelected: (data: { plainFiles?: File[] }) => {
|
|
94
|
-
if (!data.plainFiles || data.plainFiles.length === 0) return;
|
|
95
|
-
editor.getTransforms(PlaceholderPlugin).insert.media(data.plainFiles as unknown as FileList);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<>
|
|
101
|
-
<ToolbarSplitButton
|
|
102
|
-
onClick={() => {
|
|
103
|
-
openFilePicker();
|
|
104
|
-
}}
|
|
105
|
-
onKeyDown={(e) => {
|
|
106
|
-
if (e.key === 'ArrowDown') {
|
|
107
|
-
e.preventDefault();
|
|
108
|
-
setOpen(true);
|
|
109
|
-
}
|
|
110
|
-
}}
|
|
111
|
-
pressed={open}>
|
|
112
|
-
<ToolbarSplitButtonPrimary>
|
|
113
|
-
{currentConfig.icon}
|
|
114
|
-
</ToolbarSplitButtonPrimary>
|
|
115
|
-
|
|
116
|
-
<DropdownMenu
|
|
117
|
-
open={open}
|
|
118
|
-
onOpenChange={setOpen}
|
|
119
|
-
modal={false}
|
|
120
|
-
{...props}>
|
|
121
|
-
<DropdownMenuTrigger asChild>
|
|
122
|
-
<ToolbarSplitButtonSecondary />
|
|
123
|
-
</DropdownMenuTrigger>
|
|
124
|
-
|
|
125
|
-
<DropdownMenuPortal>
|
|
126
|
-
<DropdownMenuContent
|
|
127
|
-
onClick={e => e.stopPropagation()}
|
|
128
|
-
align="start"
|
|
129
|
-
alignOffset={-32}>
|
|
130
|
-
<DropdownMenuGroup>
|
|
131
|
-
<DropdownMenuItem onSelect={() => openFilePicker()}>
|
|
132
|
-
{currentConfig.icon}
|
|
133
|
-
Upload from computer
|
|
134
|
-
</DropdownMenuItem>
|
|
135
|
-
<DropdownMenuItem onSelect={() => setDialogOpen(true)}>
|
|
136
|
-
<LinkIcon />
|
|
137
|
-
Insert via URL
|
|
138
|
-
</DropdownMenuItem>
|
|
139
|
-
</DropdownMenuGroup>
|
|
140
|
-
</DropdownMenuContent>
|
|
141
|
-
</DropdownMenuPortal>
|
|
142
|
-
</DropdownMenu>
|
|
143
|
-
</ToolbarSplitButton>
|
|
144
|
-
|
|
145
|
-
<AlertDialog
|
|
146
|
-
open={dialogOpen}
|
|
147
|
-
onOpenChange={(value) => {
|
|
148
|
-
setDialogOpen(value);
|
|
149
|
-
}}>
|
|
150
|
-
<AlertDialogContent className="gap-6">
|
|
151
|
-
<MediaUrlDialogContent
|
|
152
|
-
currentConfig={currentConfig}
|
|
153
|
-
nodeType={nodeType}
|
|
154
|
-
setOpen={setDialogOpen} />
|
|
155
|
-
</AlertDialogContent>
|
|
156
|
-
</AlertDialog>
|
|
157
|
-
</>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function MediaUrlDialogContent({
|
|
162
|
-
currentConfig,
|
|
163
|
-
nodeType,
|
|
164
|
-
setOpen
|
|
165
|
-
}: {
|
|
166
|
-
currentConfig: (typeof MEDIA_CONFIG)[string];
|
|
167
|
-
nodeType: string;
|
|
168
|
-
setOpen: (value: boolean) => void;
|
|
169
|
-
}) {
|
|
170
|
-
const editor = useEditorRef();
|
|
171
|
-
const [url, setUrl] = useState('');
|
|
172
|
-
|
|
173
|
-
const embedMedia = useCallback(() => {
|
|
174
|
-
if (!isUrl(url)) return toast.error('Invalid URL');
|
|
175
|
-
|
|
176
|
-
setOpen(false);
|
|
177
|
-
editor.tf.insertNodes({
|
|
178
|
-
children: [{ text: '' }],
|
|
179
|
-
name: nodeType === KEYS.file ? url.split('/').pop() : undefined,
|
|
180
|
-
type: nodeType,
|
|
181
|
-
url
|
|
182
|
-
});
|
|
183
|
-
}, [
|
|
184
|
-
url,
|
|
185
|
-
editor,
|
|
186
|
-
nodeType,
|
|
187
|
-
setOpen
|
|
188
|
-
]);
|
|
189
|
-
|
|
190
|
-
return (
|
|
191
|
-
<>
|
|
192
|
-
<AlertDialogHeader>
|
|
193
|
-
<AlertDialogTitle>{currentConfig.title}</AlertDialogTitle>
|
|
194
|
-
</AlertDialogHeader>
|
|
195
|
-
|
|
196
|
-
<AlertDialogDescription className="group relative w-full">
|
|
197
|
-
<label
|
|
198
|
-
className="-translate-y-1/2 absolute top-1/2 block cursor-text px-1 text-muted-foreground/70 text-sm transition-all group-focus-within:pointer-events-none group-focus-within:top-0 group-focus-within:cursor-default group-focus-within:font-medium group-focus-within:text-foreground group-focus-within:text-xs has-[+input:not(:placeholder-shown)]:pointer-events-none has-[+input:not(:placeholder-shown)]:top-0 has-[+input:not(:placeholder-shown)]:cursor-default has-[+input:not(:placeholder-shown)]:font-medium has-[+input:not(:placeholder-shown)]:text-foreground has-[+input:not(:placeholder-shown)]:text-xs"
|
|
199
|
-
htmlFor="url">
|
|
200
|
-
<span className="inline-flex bg-background px-2">URL</span>
|
|
201
|
-
</label>
|
|
202
|
-
<Input
|
|
203
|
-
id="url"
|
|
204
|
-
className="w-full"
|
|
205
|
-
value={url}
|
|
206
|
-
onChange={e => setUrl(e.target.value)}
|
|
207
|
-
onKeyDown={(e) => {
|
|
208
|
-
if (e.key === 'Enter') embedMedia();
|
|
209
|
-
}}
|
|
210
|
-
placeholder=""
|
|
211
|
-
type="url"
|
|
212
|
-
autoFocus />
|
|
213
|
-
</AlertDialogDescription>
|
|
214
|
-
|
|
215
|
-
<AlertDialogFooter>
|
|
216
|
-
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
217
|
-
<AlertDialogAction
|
|
218
|
-
onClick={(e) => {
|
|
219
|
-
e.preventDefault();
|
|
220
|
-
embedMedia();
|
|
221
|
-
}}>
|
|
222
|
-
Accept
|
|
223
|
-
</AlertDialogAction>
|
|
224
|
-
</AlertDialogFooter>
|
|
225
|
-
</>
|
|
226
|
-
);
|
|
227
|
-
}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ComponentProps, type Dispatch, type SetStateAction } from 'react';
|
|
4
|
-
|
|
5
|
-
import { type TMediaElement, type TTextAlignProps, KEYS } from 'platejs';
|
|
6
|
-
|
|
7
|
-
import { showCaption } from '@platejs/caption/react';
|
|
8
|
-
import {
|
|
9
|
-
openImagePreview,
|
|
10
|
-
useMediaController,
|
|
11
|
-
useMediaControllerDropDownMenu,
|
|
12
|
-
useMediaControllerState
|
|
13
|
-
} from '@platejs/media/react';
|
|
14
|
-
import { BlockMenuPlugin } from '@platejs/selection/react';
|
|
15
|
-
import {
|
|
16
|
-
AlignCenter,
|
|
17
|
-
AlignLeft,
|
|
18
|
-
AlignRight,
|
|
19
|
-
CaptionsIcon,
|
|
20
|
-
CircleArrowDownIcon,
|
|
21
|
-
MoreHorizontalIcon,
|
|
22
|
-
MoveUpRightIcon,
|
|
23
|
-
ZoomInIcon
|
|
24
|
-
} from 'lucide-react';
|
|
25
|
-
import { useEditorRef, useElement } from 'platejs/react';
|
|
26
|
-
|
|
27
|
-
import { toast } from 'sonner';
|
|
28
|
-
|
|
29
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
30
|
-
|
|
31
|
-
import {
|
|
32
|
-
DropdownMenu,
|
|
33
|
-
DropdownMenuContent,
|
|
34
|
-
type DropdownMenuProps,
|
|
35
|
-
DropdownMenuRadioGroup,
|
|
36
|
-
DropdownMenuRadioItem,
|
|
37
|
-
DropdownMenuTrigger,
|
|
38
|
-
useOpenState
|
|
39
|
-
} from './dropdown-menu';
|
|
40
|
-
|
|
41
|
-
import { Toolbar, ToolbarButton, toolbarButtonVariants } from './toolbar';
|
|
42
|
-
|
|
43
|
-
import { downloadFile } from '../lib/download-file';
|
|
44
|
-
|
|
45
|
-
export function MediaToolbar({
|
|
46
|
-
className: _className,
|
|
47
|
-
...props
|
|
48
|
-
}: ComponentProps<typeof Toolbar>) {
|
|
49
|
-
return (
|
|
50
|
-
<Toolbar
|
|
51
|
-
className={cn(
|
|
52
|
-
'group-data-[readonly=true]/editor:hidden',
|
|
53
|
-
'top-1 right-1 opacity-0 group-hover/media:opacity-100',
|
|
54
|
-
'group-has-data-[resizing=true]/media:opacity-0 group-has-data-[state=open]/media:opacity-100 group-data-[state=open]/context-menu:opacity-0'
|
|
55
|
-
)}
|
|
56
|
-
{...props}>
|
|
57
|
-
<MediaToolbarButtons />
|
|
58
|
-
</Toolbar>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const alignItems = [
|
|
63
|
-
{
|
|
64
|
-
icon: AlignLeft,
|
|
65
|
-
value: 'left'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
icon: AlignCenter,
|
|
69
|
-
value: 'center'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
icon: AlignRight,
|
|
73
|
-
value: 'right'
|
|
74
|
-
}
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
function MediaToolbarButtons() {
|
|
78
|
-
const editor = useEditorRef();
|
|
79
|
-
const element = useElement<TMediaElement>();
|
|
80
|
-
const state = useMediaControllerState();
|
|
81
|
-
const { MediaControllerDropDownMenuProps: mediaToolbarDropDownMenuProps }
|
|
82
|
-
= useMediaController(state);
|
|
83
|
-
|
|
84
|
-
const handleDownload = () => {
|
|
85
|
-
toast.promise(downloadFile(element.url, element.id || 'file'), {
|
|
86
|
-
error: 'Download failed. Please try again.',
|
|
87
|
-
loading: 'Downloading...'
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<>
|
|
93
|
-
<MediaAlignButton {...mediaToolbarDropDownMenuProps} />
|
|
94
|
-
<ToolbarButton
|
|
95
|
-
onClick={() => showCaption(editor, element)}
|
|
96
|
-
size="none"
|
|
97
|
-
tooltip="Caption"
|
|
98
|
-
variant="media">
|
|
99
|
-
<CaptionsIcon />
|
|
100
|
-
</ToolbarButton>
|
|
101
|
-
{element.type === KEYS.img && (
|
|
102
|
-
<ToolbarButton
|
|
103
|
-
onClick={() => {
|
|
104
|
-
openImagePreview(editor, element);
|
|
105
|
-
}}
|
|
106
|
-
size="none"
|
|
107
|
-
tooltip="Expand"
|
|
108
|
-
variant="media">
|
|
109
|
-
<ZoomInIcon />
|
|
110
|
-
</ToolbarButton>
|
|
111
|
-
)}
|
|
112
|
-
|
|
113
|
-
{element.type === KEYS.img && (
|
|
114
|
-
<ToolbarButton
|
|
115
|
-
onClick={handleDownload}
|
|
116
|
-
size="none"
|
|
117
|
-
tooltip="Download"
|
|
118
|
-
variant="media">
|
|
119
|
-
<CircleArrowDownIcon />
|
|
120
|
-
</ToolbarButton>
|
|
121
|
-
)}
|
|
122
|
-
|
|
123
|
-
{element.type !== KEYS.img && (
|
|
124
|
-
<ToolbarButton
|
|
125
|
-
onClick={() => {
|
|
126
|
-
window.open(element.url, '_blank');
|
|
127
|
-
}}
|
|
128
|
-
size="none"
|
|
129
|
-
tooltip="Original"
|
|
130
|
-
variant="media">
|
|
131
|
-
<MoveUpRightIcon />
|
|
132
|
-
</ToolbarButton>
|
|
133
|
-
)}
|
|
134
|
-
|
|
135
|
-
<ToolbarButton
|
|
136
|
-
onClick={(e) => {
|
|
137
|
-
editor
|
|
138
|
-
.getApi(BlockMenuPlugin)
|
|
139
|
-
.blockMenu.showContextMenu(element.id as string, {
|
|
140
|
-
x: e.clientX,
|
|
141
|
-
y: e.clientY
|
|
142
|
-
});
|
|
143
|
-
}}
|
|
144
|
-
size="none"
|
|
145
|
-
tooltip="More actions"
|
|
146
|
-
variant="media">
|
|
147
|
-
<MoreHorizontalIcon />
|
|
148
|
-
</ToolbarButton>
|
|
149
|
-
</>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function MediaAlignButton({
|
|
154
|
-
children: _children,
|
|
155
|
-
...props
|
|
156
|
-
}: {
|
|
157
|
-
setAlignOpen: Dispatch<SetStateAction<boolean>>;
|
|
158
|
-
} & DropdownMenuProps) {
|
|
159
|
-
const editor = useEditorRef();
|
|
160
|
-
const element = useElement<TMediaElement & TTextAlignProps>();
|
|
161
|
-
const openState = useOpenState();
|
|
162
|
-
|
|
163
|
-
const value = element.align ?? 'left';
|
|
164
|
-
|
|
165
|
-
const IconValue
|
|
166
|
-
= alignItems.find(item => item.value === value)?.icon ?? AlignLeft;
|
|
167
|
-
|
|
168
|
-
useMediaControllerDropDownMenu({
|
|
169
|
-
openState,
|
|
170
|
-
setAlignOpen: props.setAlignOpen
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<DropdownMenu modal={false} {...openState} {...props}>
|
|
175
|
-
<DropdownMenuTrigger asChild>
|
|
176
|
-
<ToolbarButton
|
|
177
|
-
data-state={openState.open ? 'open' : 'closed'}
|
|
178
|
-
size="none"
|
|
179
|
-
tooltip="Align"
|
|
180
|
-
variant="media">
|
|
181
|
-
<IconValue className="size-4" />
|
|
182
|
-
</ToolbarButton>
|
|
183
|
-
</DropdownMenuTrigger>
|
|
184
|
-
|
|
185
|
-
<DropdownMenuContent
|
|
186
|
-
align="start"
|
|
187
|
-
className="min-w-0 rounded-md border-none bg-black/60 p-0 shadow-none"
|
|
188
|
-
portal={false}>
|
|
189
|
-
<DropdownMenuRadioGroup
|
|
190
|
-
className="flex hover:bg-transparent"
|
|
191
|
-
onValueChange={(value) => {
|
|
192
|
-
editor.tf.setNodes({ align: value as any }, { at: element });
|
|
193
|
-
}}
|
|
194
|
-
value={value}>
|
|
195
|
-
{alignItems.map(({ icon: Icon, value: itemValue }) => (
|
|
196
|
-
<DropdownMenuRadioItem
|
|
197
|
-
className={cn(
|
|
198
|
-
toolbarButtonVariants({
|
|
199
|
-
size: 'none',
|
|
200
|
-
variant: 'media'
|
|
201
|
-
}),
|
|
202
|
-
'size-[26px] opacity-60 hover:opacity-100 data-[state=checked]:bg-black/5 data-[state=checked]:opacity-100'
|
|
203
|
-
)}
|
|
204
|
-
hideIcon
|
|
205
|
-
key={itemValue}
|
|
206
|
-
value={itemValue}>
|
|
207
|
-
<Icon className="size-4" />
|
|
208
|
-
</DropdownMenuRadioItem>
|
|
209
|
-
))}
|
|
210
|
-
</DropdownMenuRadioGroup>
|
|
211
|
-
</DropdownMenuContent>
|
|
212
|
-
</DropdownMenu>
|
|
213
|
-
);
|
|
214
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
import { PlaceholderPlugin, UploadErrorCode } from '@platejs/media/react';
|
|
6
|
-
import { usePluginOption } from 'platejs/react';
|
|
7
|
-
import { toast } from 'sonner';
|
|
8
|
-
|
|
9
|
-
export function MediaUploadToast() {
|
|
10
|
-
useUploadErrorToast();
|
|
11
|
-
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const useUploadErrorToast = () => {
|
|
16
|
-
const uploadError = usePluginOption(PlaceholderPlugin, 'error');
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!uploadError) return;
|
|
20
|
-
|
|
21
|
-
const { code, data } = uploadError;
|
|
22
|
-
|
|
23
|
-
switch (code) {
|
|
24
|
-
case UploadErrorCode.INVALID_FILE_SIZE: {
|
|
25
|
-
toast.error(
|
|
26
|
-
`The size of files ${data.files
|
|
27
|
-
.map(f => f.name)
|
|
28
|
-
.join(', ')} is invalid`
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
case UploadErrorCode.INVALID_FILE_TYPE: {
|
|
35
|
-
toast.error(
|
|
36
|
-
`The type of files ${data.files
|
|
37
|
-
.map(f => f.name)
|
|
38
|
-
.join(', ')} is invalid`
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
case UploadErrorCode.TOO_LARGE: {
|
|
45
|
-
toast.error(
|
|
46
|
-
`The size of files ${data.files
|
|
47
|
-
.map(f => f.name)
|
|
48
|
-
.join(', ')} is too large than ${data.maxFileSize}`
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
case UploadErrorCode.TOO_LESS_FILES: {
|
|
55
|
-
toast.error(
|
|
56
|
-
`The mini um number of files is ${data.minFileCount} for ${data.fileType}`
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
case UploadErrorCode.TOO_MANY_FILES: {
|
|
63
|
-
toast.error(
|
|
64
|
-
`The maximum number of files is ${data.maxFileCount} ${
|
|
65
|
-
data.fileType ? `for ${data.fileType}` : ''
|
|
66
|
-
}`
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}, [uploadError]);
|
|
73
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
NodeApi,
|
|
4
|
-
type TCaptionElement,
|
|
5
|
-
type TResizableProps,
|
|
6
|
-
type TVideoElement
|
|
7
|
-
} from 'platejs';
|
|
8
|
-
import { SlateElement, type SlateElementProps } from 'platejs/static';
|
|
9
|
-
|
|
10
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
11
|
-
|
|
12
|
-
export function MediaVideoElementStatic(
|
|
13
|
-
props: SlateElementProps<TVideoElement & TCaptionElement & TResizableProps>
|
|
14
|
-
) {
|
|
15
|
-
const {
|
|
16
|
-
align = 'center', caption, url, width
|
|
17
|
-
} = props.element;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<SlateElement className="py-2.5" {...props}>
|
|
21
|
-
<div style={{ textAlign: align }}>
|
|
22
|
-
<figure
|
|
23
|
-
className="group relative m-0 inline-block cursor-default"
|
|
24
|
-
style={{ width }}>
|
|
25
|
-
<video
|
|
26
|
-
className={cn('w-full max-w-full object-cover px-0', 'rounded-sm')}
|
|
27
|
-
controls
|
|
28
|
-
src={url} />
|
|
29
|
-
{caption && <figcaption>{NodeApi.string(caption[0])}</figcaption>}
|
|
30
|
-
</figure>
|
|
31
|
-
</div>
|
|
32
|
-
{props.children}
|
|
33
|
-
</SlateElement>
|
|
34
|
-
);
|
|
35
|
-
}
|