@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,433 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import { AIChatPlugin } from '@platejs/ai/react';
|
|
6
|
-
import { BlockSelectionPlugin } from '@platejs/selection/react';
|
|
7
|
-
import {
|
|
8
|
-
AudioLinesIcon,
|
|
9
|
-
CalendarIcon,
|
|
10
|
-
ChevronDownIcon,
|
|
11
|
-
Code2Icon,
|
|
12
|
-
FileUpIcon,
|
|
13
|
-
FilmIcon,
|
|
14
|
-
Heading1Icon,
|
|
15
|
-
Heading2Icon,
|
|
16
|
-
Heading3Icon,
|
|
17
|
-
ImageIcon,
|
|
18
|
-
LightbulbIcon,
|
|
19
|
-
ListIcon,
|
|
20
|
-
ListOrderedIcon,
|
|
21
|
-
type LucideProps,
|
|
22
|
-
PilcrowIcon,
|
|
23
|
-
QuoteIcon,
|
|
24
|
-
RadicalIcon,
|
|
25
|
-
RectangleVerticalIcon,
|
|
26
|
-
SquareIcon,
|
|
27
|
-
TableIcon,
|
|
28
|
-
TableOfContentsIcon
|
|
29
|
-
} from 'lucide-react';
|
|
30
|
-
import { KEYS } from 'platejs';
|
|
31
|
-
import {
|
|
32
|
-
PlateElement,
|
|
33
|
-
type PlateEditor,
|
|
34
|
-
type PlateElementProps
|
|
35
|
-
} from 'platejs/react';
|
|
36
|
-
|
|
37
|
-
import {
|
|
38
|
-
insertBlock,
|
|
39
|
-
insertInlineElement,
|
|
40
|
-
setBlockType
|
|
41
|
-
} from '../editor/transforms';
|
|
42
|
-
import { blockMenuItems } from './block-menu';
|
|
43
|
-
import {
|
|
44
|
-
backgroundColorItems,
|
|
45
|
-
ColorIcon,
|
|
46
|
-
textColorItems
|
|
47
|
-
} from './font-color-toolbar-button';
|
|
48
|
-
import {
|
|
49
|
-
InlineCombobox,
|
|
50
|
-
InlineComboboxContent,
|
|
51
|
-
InlineComboboxEmpty,
|
|
52
|
-
InlineComboboxGroup,
|
|
53
|
-
InlineComboboxGroupLabel,
|
|
54
|
-
InlineComboboxInput,
|
|
55
|
-
InlineComboboxItem
|
|
56
|
-
} from './inline-combobox';
|
|
57
|
-
import { turnIntoItems } from './turn-into-toolbar-button';
|
|
58
|
-
|
|
59
|
-
type Group = {
|
|
60
|
-
group: string;
|
|
61
|
-
items: {
|
|
62
|
-
icon: ReactNode;
|
|
63
|
-
value: string;
|
|
64
|
-
onSelect: (editor: PlateEditor, value: string) => void;
|
|
65
|
-
description?: string;
|
|
66
|
-
focusEditor?: boolean;
|
|
67
|
-
keywords?: string[];
|
|
68
|
-
label?: string;
|
|
69
|
-
}[];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
function AIIcon(props: LucideProps) {
|
|
73
|
-
return (
|
|
74
|
-
<svg
|
|
75
|
-
fill="url(#myGradient)"
|
|
76
|
-
viewBox="0 0 512 512"
|
|
77
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
78
|
-
{...props}>
|
|
79
|
-
<defs>
|
|
80
|
-
<linearGradient id="myGradient" x1="0%" x2="100%" y1="0%" y2="100%">
|
|
81
|
-
<stop offset="0%" stopColor="#6EB6F2" />
|
|
82
|
-
<stop offset="15%" stopColor="#6EB6F2" />
|
|
83
|
-
<stop offset="40%" stopColor="#c084fc" />
|
|
84
|
-
<stop offset="60%" stopColor="#f87171" />
|
|
85
|
-
<stop offset="100%" stopColor="#fcd34d" />
|
|
86
|
-
</linearGradient>
|
|
87
|
-
</defs>
|
|
88
|
-
<path d="M161.15 362.26a40.902 40.902 0 0 0 23.78 7.52v-.11a40.989 40.989 0 0 0 37.75-24.8l17.43-53.02a81.642 81.642 0 0 1 51.68-51.53l50.57-16.44a41.051 41.051 0 0 0 20.11-15.31 40.964 40.964 0 0 0 7.32-24.19 41.077 41.077 0 0 0-8.23-23.89 41.051 41.051 0 0 0-20.68-14.54l-49.92-16.21a81.854 81.854 0 0 1-51.82-51.85L222.7 27.33A41.11 41.11 0 0 0 183.63.01c-8.54.07-16.86 2.8-23.78 7.81A41.152 41.152 0 0 0 145 27.97l-16.58 50.97c-4 11.73-10.61 22.39-19.33 31.19s-19.33 15.5-31.01 19.61l-50.54 16.24a41.131 41.131 0 0 0-15.89 10.14 41.059 41.059 0 0 0-9.69 16.17 41.144 41.144 0 0 0-1.44 18.8c.98 6.29 3.42 12.27 7.11 17.46a41.312 41.312 0 0 0 20.39 15.19l49.89 16.18a82.099 82.099 0 0 1 32.11 19.91c2.42 2.4 4.68 4.96 6.77 7.65a81.567 81.567 0 0 1 12.94 24.38l16.44 50.49a40.815 40.815 0 0 0 14.98 19.91zm218.06 143.57c-5.42-3.86-9.5-9.32-11.66-15.61l-9.33-28.64a37.283 37.283 0 0 0-8.9-14.48c-4.05-4.06-9-7.12-14.45-8.93l-28.19-9.19a32.655 32.655 0 0 1-16.24-12.06 32.062 32.062 0 0 1-5.97-18.74c.01-6.76 2.13-13.35 6.06-18.86 3.91-5.53 9.46-9.68 15.87-11.86l28.61-9.27a37.013 37.013 0 0 0 14.08-9.01c3.95-4.04 6.91-8.93 8.67-14.29l9.22-28.22a32.442 32.442 0 0 1 11.72-15.87 32.476 32.476 0 0 1 18.74-6.17c6.74-.07 13.33 1.96 18.86 5.81 5.53 3.84 9.74 9.31 12.03 15.64l9.36 28.84a36.832 36.832 0 0 0 8.94 14.34c4.05 4.03 8.97 7.06 14.39 8.87l28.22 9.19a32.44 32.44 0 0 1 16.29 11.52 32.465 32.465 0 0 1 6.47 18.87 32.458 32.458 0 0 1-21.65 31.19l-28.84 9.36a37.384 37.384 0 0 0-14.36 8.93c-4.05 4.06-7.1 9.01-8.9 14.45l-9.16 28.13A32.492 32.492 0 0 1 417 505.98a32.005 32.005 0 0 1-18.74 6.03 32.508 32.508 0 0 1-19.05-6.18z" />
|
|
89
|
-
</svg>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const groups: Group[] = [
|
|
94
|
-
{
|
|
95
|
-
group: 'AI',
|
|
96
|
-
items: [
|
|
97
|
-
{
|
|
98
|
-
description: 'Use AI to generate content.',
|
|
99
|
-
focusEditor: false,
|
|
100
|
-
icon: <AIIcon />,
|
|
101
|
-
keywords: [
|
|
102
|
-
'ai',
|
|
103
|
-
'generate',
|
|
104
|
-
'help',
|
|
105
|
-
'chat'
|
|
106
|
-
],
|
|
107
|
-
label: 'AI',
|
|
108
|
-
value: 'AI',
|
|
109
|
-
onSelect: (editor) => {
|
|
110
|
-
editor.getApi(AIChatPlugin).aiChat.show();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
group: 'Basic blocks',
|
|
117
|
-
items: [
|
|
118
|
-
{
|
|
119
|
-
description: 'Insert a paragraph.',
|
|
120
|
-
icon: <PilcrowIcon />,
|
|
121
|
-
keywords: ['paragraph'],
|
|
122
|
-
label: 'Text',
|
|
123
|
-
value: KEYS.p
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
description: 'Insert a large heading.',
|
|
127
|
-
icon: <Heading1Icon />,
|
|
128
|
-
keywords: ['title', 'h1'],
|
|
129
|
-
label: 'Heading 1',
|
|
130
|
-
value: KEYS.h1
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
description: 'Insert a medium heading.',
|
|
134
|
-
icon: <Heading2Icon />,
|
|
135
|
-
keywords: ['subtitle', 'h2'],
|
|
136
|
-
label: 'Heading 2',
|
|
137
|
-
value: KEYS.h2
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
description: 'Insert a small heading.',
|
|
141
|
-
icon: <Heading3Icon />,
|
|
142
|
-
keywords: ['subtitle', 'h3'],
|
|
143
|
-
label: 'Heading 3',
|
|
144
|
-
value: KEYS.h3
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
description: 'Insert a to-do list.',
|
|
148
|
-
icon: <SquareIcon />,
|
|
149
|
-
keywords: [
|
|
150
|
-
'checklist',
|
|
151
|
-
'task',
|
|
152
|
-
'checkbox',
|
|
153
|
-
'[]'
|
|
154
|
-
],
|
|
155
|
-
label: 'To-do list',
|
|
156
|
-
value: KEYS.listTodo
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
description: 'Insert a bulleted list.',
|
|
160
|
-
icon: <ListIcon />,
|
|
161
|
-
keywords: ['unordered', 'ul', '-'],
|
|
162
|
-
label: 'Bulleted list',
|
|
163
|
-
value: KEYS.ul
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
description: 'Insert a numbered list.',
|
|
167
|
-
icon: <ListOrderedIcon />,
|
|
168
|
-
keywords: ['ordered', 'ol', '1'],
|
|
169
|
-
label: 'Numbered list',
|
|
170
|
-
value: KEYS.ol
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
description: 'Insert a toggleable section.',
|
|
174
|
-
icon: <ChevronDownIcon />,
|
|
175
|
-
keywords: ['collapsible', 'expandable'],
|
|
176
|
-
label: 'Toggle',
|
|
177
|
-
value: KEYS.toggle
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
description: 'Insert a block for code.',
|
|
181
|
-
icon: <Code2Icon />,
|
|
182
|
-
keywords: ['```'],
|
|
183
|
-
label: 'Code Block',
|
|
184
|
-
value: KEYS.codeBlock
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
description: 'Create a table for data.',
|
|
188
|
-
icon: <TableIcon />,
|
|
189
|
-
label: 'Table',
|
|
190
|
-
value: KEYS.table
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
description: 'Insert a quote for emphasis.',
|
|
194
|
-
icon: <QuoteIcon />,
|
|
195
|
-
keywords: [
|
|
196
|
-
'citation',
|
|
197
|
-
'blockquote',
|
|
198
|
-
'quote',
|
|
199
|
-
'>'
|
|
200
|
-
],
|
|
201
|
-
label: 'Blockquote',
|
|
202
|
-
value: KEYS.blockquote
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
description: 'Insert a highlighted block.',
|
|
206
|
-
icon: <LightbulbIcon />,
|
|
207
|
-
keywords: ['note'],
|
|
208
|
-
label: 'Callout',
|
|
209
|
-
value: KEYS.callout
|
|
210
|
-
}
|
|
211
|
-
].map(item => ({
|
|
212
|
-
...item,
|
|
213
|
-
onSelect: (editor: PlateEditor, value: string) => {
|
|
214
|
-
insertBlock(editor, value);
|
|
215
|
-
}
|
|
216
|
-
}))
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
group: 'Media',
|
|
220
|
-
items: [
|
|
221
|
-
{
|
|
222
|
-
description: 'Upload or embed an image.',
|
|
223
|
-
icon: <ImageIcon />,
|
|
224
|
-
keywords: [
|
|
225
|
-
'media',
|
|
226
|
-
'img',
|
|
227
|
-
'picture',
|
|
228
|
-
'photo'
|
|
229
|
-
],
|
|
230
|
-
label: 'Image',
|
|
231
|
-
value: KEYS.img
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
description: 'Upload or embed a video.',
|
|
235
|
-
icon: <FilmIcon />,
|
|
236
|
-
keywords: ['media', 'video', 'movie'],
|
|
237
|
-
label: 'Video',
|
|
238
|
-
value: KEYS.video
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
description: 'Upload or embed audio.',
|
|
242
|
-
icon: <AudioLinesIcon />,
|
|
243
|
-
keywords: ['media', 'audio', 'sound'],
|
|
244
|
-
label: 'Audio',
|
|
245
|
-
value: KEYS.audio
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
description: 'Upload or link any file type.',
|
|
249
|
-
icon: <FileUpIcon />,
|
|
250
|
-
keywords: [
|
|
251
|
-
'media',
|
|
252
|
-
'file',
|
|
253
|
-
'document',
|
|
254
|
-
'attachment'
|
|
255
|
-
],
|
|
256
|
-
label: 'File',
|
|
257
|
-
value: KEYS.file
|
|
258
|
-
}
|
|
259
|
-
].map(item => ({
|
|
260
|
-
...item,
|
|
261
|
-
focusEditor: false,
|
|
262
|
-
onSelect: (editor: PlateEditor, value: string) => {
|
|
263
|
-
insertBlock(editor, value);
|
|
264
|
-
}
|
|
265
|
-
}))
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
group: 'Advanced blocks',
|
|
269
|
-
items: [
|
|
270
|
-
{
|
|
271
|
-
description: 'Generate a table of contents.',
|
|
272
|
-
icon: <TableOfContentsIcon />,
|
|
273
|
-
keywords: ['toc'],
|
|
274
|
-
label: 'Table of content',
|
|
275
|
-
value: KEYS.toc
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
description: 'Insert a block for equations.',
|
|
279
|
-
focusEditor: false,
|
|
280
|
-
icon: <RadicalIcon />,
|
|
281
|
-
keywords: ['math', 'formula'],
|
|
282
|
-
label: 'Equation',
|
|
283
|
-
value: KEYS.equation
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
description: 'Create 3 columns of blocks.',
|
|
287
|
-
icon: <RectangleVerticalIcon />,
|
|
288
|
-
label: '3 columns',
|
|
289
|
-
value: 'action_three_columns'
|
|
290
|
-
}
|
|
291
|
-
].map(item => ({
|
|
292
|
-
...item,
|
|
293
|
-
onSelect: (editor: PlateEditor, value: string) => {
|
|
294
|
-
insertBlock(editor, value);
|
|
295
|
-
}
|
|
296
|
-
}))
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
group: 'Inline',
|
|
300
|
-
items: [
|
|
301
|
-
{
|
|
302
|
-
description: 'Insert an inline math equation.',
|
|
303
|
-
focusEditor: false,
|
|
304
|
-
icon: <RadicalIcon />,
|
|
305
|
-
keywords: ['math', 'inline', 'formula'],
|
|
306
|
-
label: 'Inline Equation',
|
|
307
|
-
value: KEYS.inlineEquation
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
description: 'Insert current or custom date.',
|
|
311
|
-
focusEditor: true,
|
|
312
|
-
icon: <CalendarIcon />,
|
|
313
|
-
keywords: ['time'],
|
|
314
|
-
label: 'Date',
|
|
315
|
-
value: KEYS.date
|
|
316
|
-
}
|
|
317
|
-
].map(item => ({
|
|
318
|
-
...item,
|
|
319
|
-
onSelect: (editor: PlateEditor, value: string) => {
|
|
320
|
-
insertInlineElement(editor, value);
|
|
321
|
-
}
|
|
322
|
-
}))
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
group: 'Turn into',
|
|
326
|
-
items: turnIntoItems.map(item => ({
|
|
327
|
-
...item,
|
|
328
|
-
onSelect: (editor: PlateEditor) => {
|
|
329
|
-
setBlockType(editor, item.value);
|
|
330
|
-
}
|
|
331
|
-
}))
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
group: 'Actions',
|
|
335
|
-
items: [
|
|
336
|
-
{
|
|
337
|
-
...blockMenuItems.delete,
|
|
338
|
-
onSelect: (editor: PlateEditor) => {
|
|
339
|
-
editor.tf.removeNodes();
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
...blockMenuItems.duplicate,
|
|
344
|
-
onSelect: (editor: PlateEditor) => {
|
|
345
|
-
editor.getTransforms(BlockSelectionPlugin).blockSelection.duplicate();
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
]
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
group: 'Text color',
|
|
352
|
-
items: textColorItems.map(item => ({
|
|
353
|
-
...item,
|
|
354
|
-
icon: <ColorIcon group="color" value={item.value} />,
|
|
355
|
-
onSelect: (editor: PlateEditor) => {
|
|
356
|
-
editor.tf.setNodes(
|
|
357
|
-
{ color: item.value },
|
|
358
|
-
{ at: editor.api.block()![1], mode: 'lowest' }
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}))
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
group: 'Background color',
|
|
365
|
-
items: backgroundColorItems.map(item => ({
|
|
366
|
-
...item,
|
|
367
|
-
icon: <ColorIcon group="background" value={item.value} />,
|
|
368
|
-
onSelect: (editor: PlateEditor) => {
|
|
369
|
-
editor.tf.setNodes(
|
|
370
|
-
{ backgroundColor: item.value },
|
|
371
|
-
{ at: editor.api.block()![1] }
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
}))
|
|
375
|
-
}
|
|
376
|
-
];
|
|
377
|
-
|
|
378
|
-
export function SlashInputElement(props: PlateElementProps) {
|
|
379
|
-
const { children, editor, element } = props;
|
|
380
|
-
|
|
381
|
-
return (
|
|
382
|
-
<PlateElement {...props} as="span">
|
|
383
|
-
<InlineCombobox element={element} trigger="/">
|
|
384
|
-
<InlineComboboxInput />
|
|
385
|
-
|
|
386
|
-
<InlineComboboxContent variant="slash">
|
|
387
|
-
<InlineComboboxEmpty>No results</InlineComboboxEmpty>
|
|
388
|
-
|
|
389
|
-
{groups.map(({ group, items }) => (
|
|
390
|
-
<InlineComboboxGroup key={group}>
|
|
391
|
-
<InlineComboboxGroupLabel>{group}</InlineComboboxGroupLabel>
|
|
392
|
-
{items.map(
|
|
393
|
-
item => (
|
|
394
|
-
<InlineComboboxItem
|
|
395
|
-
focusEditor={(item as any).focusEditor}
|
|
396
|
-
group={group}
|
|
397
|
-
key={item.value}
|
|
398
|
-
keywords={item.keywords}
|
|
399
|
-
label={item.label}
|
|
400
|
-
onClick={() => item.onSelect(editor, item.value)}
|
|
401
|
-
value={item.value}>
|
|
402
|
-
{item.description ? (
|
|
403
|
-
<>
|
|
404
|
-
<div className="flex size-11 items-center justify-center rounded border border-foreground/15 bg-white [&_svg]:size-5 [&_svg]:text-subtle-foreground">
|
|
405
|
-
{item.icon}
|
|
406
|
-
</div>
|
|
407
|
-
<div className="ml-3 flex flex-1 flex-col truncate">
|
|
408
|
-
<span>{item.label ?? item.value}</span>
|
|
409
|
-
<span className="truncate text-muted-foreground text-xs">
|
|
410
|
-
{item.description}
|
|
411
|
-
</span>
|
|
412
|
-
</div>
|
|
413
|
-
</>
|
|
414
|
-
) : (
|
|
415
|
-
<>
|
|
416
|
-
<div className="mr-2 text-subtle-foreground">
|
|
417
|
-
{item.icon}
|
|
418
|
-
</div>
|
|
419
|
-
{item.label ?? item.value}
|
|
420
|
-
</>
|
|
421
|
-
)}
|
|
422
|
-
</InlineComboboxItem>
|
|
423
|
-
)
|
|
424
|
-
)}
|
|
425
|
-
</InlineComboboxGroup>
|
|
426
|
-
))}
|
|
427
|
-
</InlineComboboxContent>
|
|
428
|
-
</InlineCombobox>
|
|
429
|
-
|
|
430
|
-
{children}
|
|
431
|
-
</PlateElement>
|
|
432
|
-
);
|
|
433
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Spinner } from '@docyrus/ui-pro-shared/spinner';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { type TSuggestionText } from 'platejs';
|
|
3
|
-
|
|
4
|
-
import { BaseSuggestionPlugin } from '@platejs/suggestion';
|
|
5
|
-
|
|
6
|
-
import { SlateLeaf, type SlateLeafProps } from 'platejs/static';
|
|
7
|
-
|
|
8
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
9
|
-
|
|
10
|
-
export function SuggestionLeafStatic(props: SlateLeafProps<TSuggestionText>) {
|
|
11
|
-
const { editor, leaf } = props;
|
|
12
|
-
|
|
13
|
-
const dataList = editor
|
|
14
|
-
.getApi(BaseSuggestionPlugin)
|
|
15
|
-
.suggestion.dataList(leaf);
|
|
16
|
-
const hasRemove = dataList.some((data: { type: string }) => data.type === 'remove');
|
|
17
|
-
const diffOperation = { type: hasRemove ? 'delete' : 'insert' } as const;
|
|
18
|
-
|
|
19
|
-
const Component = ({ delete: 'del', insert: 'ins', update: 'span' } as const)[
|
|
20
|
-
diffOperation.type
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<SlateLeaf
|
|
25
|
-
{...props}
|
|
26
|
-
as={Component}
|
|
27
|
-
className={cn(
|
|
28
|
-
'border-b-2 border-b-brand/[.24] bg-brand/8 text-brand/80 no-underline transition-colors duration-200',
|
|
29
|
-
hasRemove
|
|
30
|
-
&& 'border-b-gray-300 bg-gray-300/25 text-gray-400 line-through'
|
|
31
|
-
)}>
|
|
32
|
-
{props.children}
|
|
33
|
-
</SlateLeaf>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useRef, type ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import { type TSuggestionData, type TSuggestionText } from 'platejs';
|
|
6
|
-
|
|
7
|
-
import { cva } from 'class-variance-authority';
|
|
8
|
-
import { CornerDownLeftIcon } from 'lucide-react';
|
|
9
|
-
import {
|
|
10
|
-
PlateLeaf,
|
|
11
|
-
type PlateLeafProps,
|
|
12
|
-
type RenderNodeWrapper,
|
|
13
|
-
useEditorPlugin,
|
|
14
|
-
usePluginOption
|
|
15
|
-
} from 'platejs/react';
|
|
16
|
-
|
|
17
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
18
|
-
|
|
19
|
-
import { type SuggestionConfig, suggestionPlugin } from '../editor/plugins/suggestion-kit';
|
|
20
|
-
|
|
21
|
-
const suggestionVariants = cva(
|
|
22
|
-
cn(
|
|
23
|
-
'bg-emerald-100 text-emerald-700 no-underline transition-colors duration-200'
|
|
24
|
-
),
|
|
25
|
-
{
|
|
26
|
-
defaultVariants: {
|
|
27
|
-
insertActive: false,
|
|
28
|
-
remove: false,
|
|
29
|
-
removeActive: false
|
|
30
|
-
},
|
|
31
|
-
variants: {
|
|
32
|
-
insertActive: {
|
|
33
|
-
false: '',
|
|
34
|
-
true: 'bg-emerald-200/80'
|
|
35
|
-
},
|
|
36
|
-
remove: {
|
|
37
|
-
false: '',
|
|
38
|
-
true: 'bg-red-100 text-red-700'
|
|
39
|
-
},
|
|
40
|
-
removeActive: {
|
|
41
|
-
false: '',
|
|
42
|
-
true: 'bg-red-200/80 no-underline'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
export function SuggestionLeaf(props: PlateLeafProps<TSuggestionText>) {
|
|
49
|
-
const { api, setOption } = useEditorPlugin(suggestionPlugin);
|
|
50
|
-
|
|
51
|
-
const leafId: string = api.suggestion.nodeId(props.leaf) ?? '';
|
|
52
|
-
const activeSuggestionId = usePluginOption(suggestionPlugin, 'activeId');
|
|
53
|
-
const hoverSuggestionId = usePluginOption(suggestionPlugin, 'hoverId');
|
|
54
|
-
const dataList = api.suggestion.dataList(props.leaf);
|
|
55
|
-
|
|
56
|
-
const hasRemove = dataList.some(data => data.type === 'remove');
|
|
57
|
-
const hasActive = dataList.some(data => data.id === activeSuggestionId);
|
|
58
|
-
const hasHover = dataList.some(data => data.id === hoverSuggestionId);
|
|
59
|
-
|
|
60
|
-
const diffOperation = {
|
|
61
|
-
type: hasRemove ? 'delete' : 'insert'
|
|
62
|
-
} as const;
|
|
63
|
-
|
|
64
|
-
const Component = (
|
|
65
|
-
{
|
|
66
|
-
delete: 'del',
|
|
67
|
-
insert: 'ins',
|
|
68
|
-
update: 'span'
|
|
69
|
-
} as const
|
|
70
|
-
)[diffOperation.type];
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<PlateLeaf
|
|
74
|
-
{...props}
|
|
75
|
-
as={Component}
|
|
76
|
-
attributes={{
|
|
77
|
-
...props.attributes,
|
|
78
|
-
onMouseEnter: () => setOption('hoverId', leafId),
|
|
79
|
-
onMouseLeave: () => setOption('hoverId', null)
|
|
80
|
-
}}
|
|
81
|
-
className={suggestionVariants({
|
|
82
|
-
insertActive: hasActive || hasHover,
|
|
83
|
-
remove: hasRemove,
|
|
84
|
-
removeActive: (hasActive || hasHover) && hasRemove
|
|
85
|
-
})} />
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const SuggestionLineBreak: RenderNodeWrapper<SuggestionConfig> = ({
|
|
90
|
-
api,
|
|
91
|
-
element
|
|
92
|
-
}) => {
|
|
93
|
-
if (!api.suggestion.isBlockSuggestion(element)) return;
|
|
94
|
-
|
|
95
|
-
const suggestionData = element.suggestion;
|
|
96
|
-
|
|
97
|
-
return function Component({ children }: { children: ReactNode }) {
|
|
98
|
-
return (
|
|
99
|
-
<SuggestionLineBreakContent suggestionData={suggestionData}>
|
|
100
|
-
{children}
|
|
101
|
-
</SuggestionLineBreakContent>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
function SuggestionLineBreakContent({
|
|
107
|
-
children,
|
|
108
|
-
suggestionData
|
|
109
|
-
}: {
|
|
110
|
-
children: ReactNode;
|
|
111
|
-
suggestionData: TSuggestionData;
|
|
112
|
-
}) {
|
|
113
|
-
const { isLineBreak, type } = suggestionData;
|
|
114
|
-
const isRemove = type === 'remove';
|
|
115
|
-
const isInsert = type === 'insert';
|
|
116
|
-
|
|
117
|
-
const activeSuggestionId = usePluginOption(suggestionPlugin, 'activeId');
|
|
118
|
-
const hoverSuggestionId = usePluginOption(suggestionPlugin, 'hoverId');
|
|
119
|
-
|
|
120
|
-
const isActive = activeSuggestionId === suggestionData.id;
|
|
121
|
-
const isHover = hoverSuggestionId === suggestionData.id;
|
|
122
|
-
|
|
123
|
-
const spanRef = useRef<HTMLSpanElement>(null);
|
|
124
|
-
const { setOption } = useEditorPlugin(suggestionPlugin);
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<>
|
|
128
|
-
{isLineBreak ? (
|
|
129
|
-
<>
|
|
130
|
-
{children}
|
|
131
|
-
<span
|
|
132
|
-
className={cn(
|
|
133
|
-
'absolute text-justify',
|
|
134
|
-
suggestionVariants({
|
|
135
|
-
insertActive: isInsert && (isActive || isHover),
|
|
136
|
-
remove: isRemove,
|
|
137
|
-
removeActive: (isActive || isHover) && isRemove
|
|
138
|
-
})
|
|
139
|
-
)}
|
|
140
|
-
contentEditable={false}
|
|
141
|
-
ref={spanRef}
|
|
142
|
-
style={{
|
|
143
|
-
bottom: 3.5,
|
|
144
|
-
height: 21
|
|
145
|
-
}}>
|
|
146
|
-
<CornerDownLeftIcon className="mt-0.5 size-4" />
|
|
147
|
-
</span>
|
|
148
|
-
</>
|
|
149
|
-
) : (
|
|
150
|
-
<div
|
|
151
|
-
className={cn(
|
|
152
|
-
suggestionVariants({
|
|
153
|
-
insertActive: isInsert && (isActive || isHover),
|
|
154
|
-
remove: isRemove,
|
|
155
|
-
removeActive: (isActive || isHover) && isRemove
|
|
156
|
-
})
|
|
157
|
-
)}
|
|
158
|
-
data-block-suggestion="true"
|
|
159
|
-
onMouseEnter={() => setOption('hoverId', suggestionData.id)}
|
|
160
|
-
onMouseLeave={() => setOption('hoverId', null)}>
|
|
161
|
-
{children}
|
|
162
|
-
</div>
|
|
163
|
-
)}
|
|
164
|
-
</>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { SuggestionPlugin } from '@platejs/suggestion/react';
|
|
4
|
-
import { PencilLineIcon } from 'lucide-react';
|
|
5
|
-
import { useEditorPlugin, usePluginOption } from 'platejs/react';
|
|
6
|
-
|
|
7
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
8
|
-
|
|
9
|
-
import { ToolbarButton } from './toolbar';
|
|
10
|
-
|
|
11
|
-
export function SuggestionToolbarButton() {
|
|
12
|
-
const { setOption } = useEditorPlugin(SuggestionPlugin);
|
|
13
|
-
const isSuggesting = usePluginOption(SuggestionPlugin, 'isSuggesting');
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<ToolbarButton
|
|
17
|
-
className={cn(isSuggesting && 'text-brand/80 hover:text-brand/80')}
|
|
18
|
-
onClick={() => setOption('isSuggesting', !isSuggesting)}
|
|
19
|
-
onMouseDown={e => e.preventDefault()}
|
|
20
|
-
tooltip={isSuggesting ? 'Turn off suggesting' : 'Suggestion edits'}>
|
|
21
|
-
<PencilLineIcon />
|
|
22
|
-
</ToolbarButton>
|
|
23
|
-
);
|
|
24
|
-
}
|