@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/assistant-animations.d.ts +3 -3
- package/dist/docy-assistant.d.ts +1 -1
- package/dist/index.js +74 -47
- package/dist/index.js.map +1 -1
- package/dist/styles.css +5137 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/views/assistant-view.d.ts +2 -2
- package/package.json +38 -36
- package/src/components/assistant-animations.tsx +0 -29
- package/src/components/assistant-dialogs.tsx +0 -235
- package/src/components/code-view.tsx +0 -278
- package/src/components/create-agent-task.tsx +0 -104
- package/src/components/create-new-work-version.tsx +0 -30
- package/src/components/extract-web.tsx +0 -160
- package/src/components/forward-to-agent.tsx +0 -90
- package/src/components/generate-chart.tsx +0 -101
- package/src/components/generative-action-button.tsx +0 -122
- package/src/components/generative-tool.tsx +0 -685
- package/src/components/generative-ui-object.tsx +0 -210
- package/src/components/input-area.tsx +0 -1209
- package/src/components/json-schema-layout.tsx +0 -326
- package/src/components/list-item-card.tsx +0 -92
- package/src/components/mermaid-diagram.tsx +0 -192
- package/src/components/preview-image.tsx +0 -47
- package/src/components/request-approval.tsx +0 -48
- package/src/components/request-user-input.tsx +0 -270
- package/src/components/search-web.tsx +0 -319
- package/src/components/sheet-command.tsx +0 -88
- package/src/components/shell-canvas.tsx +0 -122
- package/src/components/show-advanced-data-table.tsx +0 -352
- package/src/components/show-generated-content-options.tsx +0 -93
- package/src/components/show-people-cards.tsx +0 -180
- package/src/components/subagent-tool.tsx +0 -180
- package/src/components/text-editor-tool.tsx +0 -328
- package/src/components/work-canvas.tsx +0 -88
- package/src/components/work-card.tsx +0 -42
- package/src/declarations.d.ts +0 -1
- package/src/docy-assistant.tsx +0 -1962
- package/src/hooks/index.ts +0 -7
- package/src/hooks/use-assistant-api.ts +0 -507
- package/src/hooks/use-deployment-data.ts +0 -162
- package/src/hooks/use-project-state.ts +0 -347
- package/src/hooks/use-session-state.ts +0 -207
- package/src/hooks/use-speech-recognition.ts +0 -137
- package/src/hooks/use-ui-state.ts +0 -185
- package/src/hooks/use-works-state.ts +0 -146
- package/src/i18n/context.tsx +0 -253
- package/src/i18n/index.ts +0 -19
- package/src/i18n/locales/de.json +0 -198
- package/src/i18n/locales/el.json +0 -198
- package/src/i18n/locales/en.json +0 -226
- package/src/i18n/locales/es.json +0 -198
- package/src/i18n/locales/fr.json +0 -198
- package/src/i18n/locales/it.json +0 -198
- package/src/i18n/locales/pt.json +0 -198
- package/src/i18n/locales/sl.json +0 -198
- package/src/i18n/locales/tr.json +0 -211
- package/src/i18n/types.ts +0 -23
- package/src/i18n/use-translation.ts +0 -17
- package/src/index.ts +0 -18
- package/src/internal/plate-editor/editor/auth-context.ts +0 -11
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +0 -39
- package/src/internal/plate-editor/editor/editor-kit.tsx +0 -89
- package/src/internal/plate-editor/editor/plate-editor.tsx +0 -75
- package/src/internal/plate-editor/editor/plate-types.ts +0 -126
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +0 -172
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +0 -211
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +0 -51
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +0 -38
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +0 -31
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +0 -23
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +0 -174
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +0 -68
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +0 -13
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +0 -43
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +0 -15
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +0 -12
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +0 -47
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +0 -35
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +0 -18
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +0 -10
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +0 -37
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +0 -53
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +0 -95
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +0 -20
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +0 -9
- package/src/internal/plate-editor/editor/transforms.ts +0 -165
- package/src/internal/plate-editor/editor/use-chat.ts +0 -152
- package/src/internal/plate-editor/hooks/index.ts +0 -3
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +0 -31
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +0 -26
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +0 -21
- package/src/internal/plate-editor/hooks/use-media-query.ts +0 -44
- package/src/internal/plate-editor/hooks/use-mounted.ts +0 -18
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +0 -114
- package/src/internal/plate-editor/hooks/use-upload-file.ts +0 -81
- package/src/internal/plate-editor/i18n/context.tsx +0 -58
- package/src/internal/plate-editor/i18n/index.ts +0 -3
- package/src/internal/plate-editor/i18n/locales/de.json +0 -57
- package/src/internal/plate-editor/i18n/locales/el.json +0 -57
- package/src/internal/plate-editor/i18n/locales/en.json +0 -57
- package/src/internal/plate-editor/i18n/locales/es.json +0 -57
- package/src/internal/plate-editor/i18n/locales/fr.json +0 -57
- package/src/internal/plate-editor/i18n/locales/it.json +0 -57
- package/src/internal/plate-editor/i18n/locales/pt.json +0 -57
- package/src/internal/plate-editor/i18n/locales/sl.json +0 -57
- package/src/internal/plate-editor/i18n/locales/tr.json +0 -57
- package/src/internal/plate-editor/i18n/types.ts +0 -59
- package/src/internal/plate-editor/i18n/use-translation.ts +0 -22
- package/src/internal/plate-editor/index.ts +0 -39
- package/src/internal/plate-editor/lib/ai-output-converter.ts +0 -153
- package/src/internal/plate-editor/lib/download-file.ts +0 -17
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +0 -828
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +0 -145
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +0 -88
- package/src/internal/plate-editor/plate-ui/avatar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +0 -104
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +0 -364
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +0 -557
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +0 -77
- package/src/internal/plate-editor/plate-ui/block-list.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +0 -555
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +0 -469
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +0 -10
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/button.tsx +0 -201
- package/src/internal/plate-editor/plate-ui/calendar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +0 -76
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/caption.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +0 -172
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/code-node.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +0 -65
- package/src/internal/plate-editor/plate-ui/column-node.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/command.tsx +0 -202
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +0 -45
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/comment.tsx +0 -619
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +0 -43
- package/src/internal/plate-editor/plate-ui/date-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/dialog.tsx +0 -445
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +0 -264
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +0 -40
- package/src/internal/plate-editor/plate-ui/editor.tsx +0 -146
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +0 -626
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +0 -155
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +0 -26
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +0 -206
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +0 -157
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +0 -1129
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +0 -129
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +0 -97
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +0 -209
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +0 -152
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +0 -20
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +0 -56
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +0 -9
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +0 -50
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +0 -7
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +0 -122
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +0 -409
- package/src/internal/plate-editor/plate-ui/input.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +0 -258
- package/src/internal/plate-editor/plate-ui/label.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +0 -69
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/link-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +0 -147
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +0 -177
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +0 -21
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +0 -103
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +0 -30
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +0 -183
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +0 -441
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +0 -127
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +0 -227
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +0 -214
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +0 -73
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +0 -119
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +0 -46
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/menu.tsx +0 -539
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +0 -124
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +0 -16
- package/src/internal/plate-editor/plate-ui/popover.tsx +0 -75
- package/src/internal/plate-editor/plate-ui/progress.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +0 -86
- package/src/internal/plate-editor/plate-ui/separator.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +0 -433
- package/src/internal/plate-editor/plate-ui/spinner.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +0 -166
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +0 -84
- package/src/internal/plate-editor/plate-ui/table-node.tsx +0 -283
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +0 -252
- package/src/internal/plate-editor/plate-ui/tabs.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/textarea.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +0 -142
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/toggle.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +0 -378
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +0 -148
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +0 -175
- package/src/internal/plate-editor/types/index.ts +0 -22
- package/src/internal/plate-editor/vite.ts +0 -284
- package/src/internal/sheets/components/univer-sheets.tsx +0 -1104
- package/src/internal/sheets/i18n/context.tsx +0 -183
- package/src/internal/sheets/i18n/index.ts +0 -19
- package/src/internal/sheets/i18n/locales/de.json +0 -21
- package/src/internal/sheets/i18n/locales/el.json +0 -21
- package/src/internal/sheets/i18n/locales/en.json +0 -21
- package/src/internal/sheets/i18n/locales/es.json +0 -21
- package/src/internal/sheets/i18n/locales/fr.json +0 -21
- package/src/internal/sheets/i18n/locales/it.json +0 -21
- package/src/internal/sheets/i18n/locales/pt.json +0 -21
- package/src/internal/sheets/i18n/locales/sl.json +0 -21
- package/src/internal/sheets/i18n/locales/tr.json +0 -21
- package/src/internal/sheets/i18n/types.ts +0 -23
- package/src/internal/sheets/i18n/use-translation.ts +0 -17
- package/src/internal/sheets/index.ts +0 -14
- package/src/internal/sheets/types/css.d.ts +0 -11
- package/src/internal/sheets/types/index.ts +0 -260
- package/src/internal/sheets/xlsx.ts +0 -1169
- package/src/lib/api-client.ts +0 -77
- package/src/lib/assistant-api-actions.ts +0 -549
- package/src/lib/assistant-config.tsx +0 -75
- package/src/lib/class-utils.ts +0 -40
- package/src/lib/index.ts +0 -7
- package/src/lib/message-utils.ts +0 -131
- package/src/tools/tools-schema.json +0 -512
- package/src/types/index.ts +0 -235
- package/src/views/assistant-view.tsx +0 -1137
- package/src/views/canvas-app.tsx +0 -839
- package/src/views/canvas-code.tsx +0 -93
- package/src/views/canvas-deep-research.tsx +0 -44
- package/src/views/canvas-image.tsx +0 -25
- package/src/views/canvas-record-view.tsx +0 -285
- package/src/views/canvas-spreadsheet.tsx +0 -125
- package/src/views/canvas-text.tsx +0 -52
- package/src/views/canvas.tsx +0 -274
- package/src/views/chat-panel.tsx +0 -149
- package/src/views/index.ts +0 -20
- package/src/views/memories-panel.tsx +0 -365
- package/src/views/message-list.tsx +0 -370
- package/src/views/project-detail.tsx +0 -257
- package/src/views/projects-panel.tsx +0 -131
- package/src/views/sessions-list.tsx +0 -98
- package/src/views/sidebar-content.tsx +0 -256
- package/src/views/work-detail.tsx +0 -98
- package/src/vite.ts +0 -64
- package/src/worker.ts +0 -203
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { BaseTocPlugin, type Heading, isHeading } from '@platejs/toc';
|
|
3
|
-
import { cva } from 'class-variance-authority';
|
|
4
|
-
import {
|
|
5
|
-
KEYS, NodeApi, type SlateEditor, type TElement
|
|
6
|
-
} from 'platejs';
|
|
7
|
-
import { SlateElement, type SlateElementProps } from 'platejs/static';
|
|
8
|
-
|
|
9
|
-
import { Button } from './button';
|
|
10
|
-
|
|
11
|
-
const headingItemVariants = cva(
|
|
12
|
-
'block h-auto w-full cursor-pointer truncate rounded-none px-0.5 py-1.5 text-left font-medium text-muted-foreground underline decoration-[0.5px] underline-offset-4 hover:bg-accent hover:text-muted-foreground',
|
|
13
|
-
{
|
|
14
|
-
variants: {
|
|
15
|
-
depth: {
|
|
16
|
-
1: 'pl-0.5',
|
|
17
|
-
2: 'pl-[26px]',
|
|
18
|
-
3: 'pl-[50px]'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export function TocElementStatic(props: SlateElementProps) {
|
|
25
|
-
const { editor } = props;
|
|
26
|
-
const headingList = getHeadingList(editor);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<SlateElement {...props} className="mb-1 p-0">
|
|
30
|
-
<div>
|
|
31
|
-
{headingList.length > 0 ? (
|
|
32
|
-
headingList.map(item => (
|
|
33
|
-
<Button
|
|
34
|
-
className={headingItemVariants({ depth: item.depth as any })}
|
|
35
|
-
key={item.title}
|
|
36
|
-
variant="ghost">
|
|
37
|
-
{item.title}
|
|
38
|
-
</Button>
|
|
39
|
-
))
|
|
40
|
-
) : (
|
|
41
|
-
<div className="text-gray-500 text-sm">
|
|
42
|
-
Create a heading to display the table of contents.
|
|
43
|
-
</div>
|
|
44
|
-
)}
|
|
45
|
-
</div>
|
|
46
|
-
{props.children}
|
|
47
|
-
</SlateElement>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const headingLevels = {
|
|
52
|
-
[KEYS.h1]: 1,
|
|
53
|
-
[KEYS.h2]: 2,
|
|
54
|
-
[KEYS.h3]: 3,
|
|
55
|
-
[KEYS.h4]: 4,
|
|
56
|
-
[KEYS.h5]: 5,
|
|
57
|
-
[KEYS.h6]: 6
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const getHeadingList = (editor?: SlateEditor) => {
|
|
61
|
-
if (!editor) return [];
|
|
62
|
-
|
|
63
|
-
const options = editor.getOptions(BaseTocPlugin);
|
|
64
|
-
|
|
65
|
-
if (options.queryHeading) {
|
|
66
|
-
return options.queryHeading(editor);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const headingList: Heading[] = [];
|
|
70
|
-
|
|
71
|
-
const values = editor.api.nodes({
|
|
72
|
-
at: [],
|
|
73
|
-
match: (n: TElement) => isHeading(n)
|
|
74
|
-
}) as Array<[TElement, any]>;
|
|
75
|
-
|
|
76
|
-
if (!values) return [];
|
|
77
|
-
|
|
78
|
-
for (const [node, path] of values) {
|
|
79
|
-
const { type } = node as TElement;
|
|
80
|
-
const title = NodeApi.string(node);
|
|
81
|
-
const depth = headingLevels[type as keyof typeof headingLevels];
|
|
82
|
-
const id = node.id as string;
|
|
83
|
-
|
|
84
|
-
if (title) {
|
|
85
|
-
headingList.push({
|
|
86
|
-
id, depth, path, title, type
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return headingList;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* DOCX-compatible TOC component.
|
|
96
|
-
* Renders TOC items as anchor links for proper Word internal navigation.
|
|
97
|
-
*/
|
|
98
|
-
export function TocElementDocx(props: SlateElementProps) {
|
|
99
|
-
const { editor } = props;
|
|
100
|
-
const headingList = getHeadingList(editor);
|
|
101
|
-
|
|
102
|
-
const depthIndent: Record<number, string> = {
|
|
103
|
-
1: '0',
|
|
104
|
-
2: '24pt',
|
|
105
|
-
3: '48pt'
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<SlateElement {...props}>
|
|
110
|
-
<div
|
|
111
|
-
style={{
|
|
112
|
-
marginBottom: '12pt',
|
|
113
|
-
padding: '8pt 0'
|
|
114
|
-
}}>
|
|
115
|
-
{headingList.length > 0 ? (
|
|
116
|
-
headingList.map(item => (
|
|
117
|
-
<p
|
|
118
|
-
key={item.id}
|
|
119
|
-
style={{
|
|
120
|
-
margin: '4pt 0',
|
|
121
|
-
paddingLeft: depthIndent[item.depth] || '0'
|
|
122
|
-
}}>
|
|
123
|
-
<a
|
|
124
|
-
href={`#${item.id}`}
|
|
125
|
-
style={{
|
|
126
|
-
color: '#0066cc',
|
|
127
|
-
textDecoration: 'underline'
|
|
128
|
-
}}>
|
|
129
|
-
{item.title}
|
|
130
|
-
</a>
|
|
131
|
-
</p>
|
|
132
|
-
))
|
|
133
|
-
) : (
|
|
134
|
-
<p style={{ color: '#666', fontSize: '10pt' }}>
|
|
135
|
-
Create a heading to display the table of contents.
|
|
136
|
-
</p>
|
|
137
|
-
)}
|
|
138
|
-
</div>
|
|
139
|
-
{props.children}
|
|
140
|
-
</SlateElement>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { BlockSelectionPlugin } from '@platejs/selection/react';
|
|
2
|
-
import { useTocElement, useTocElementState } from '@platejs/toc/react';
|
|
3
|
-
import { cva } from 'class-variance-authority';
|
|
4
|
-
import { PlateElement, type PlateElementProps } from 'platejs/react';
|
|
5
|
-
|
|
6
|
-
import { Button } from './button';
|
|
7
|
-
|
|
8
|
-
const headingItemVariants = cva(
|
|
9
|
-
'block h-auto w-full cursor-pointer truncate rounded-none px-0.5 py-1.5 text-left font-medium text-muted-foreground underline decoration-[0.5px] underline-offset-4 hover:bg-accent hover:text-muted-foreground',
|
|
10
|
-
{
|
|
11
|
-
variants: {
|
|
12
|
-
depth: {
|
|
13
|
-
1: 'pl-0.5',
|
|
14
|
-
2: 'pl-[26px]',
|
|
15
|
-
3: 'pl-[50px]'
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export function TocElement(props: PlateElementProps) {
|
|
22
|
-
const { editor, element } = props;
|
|
23
|
-
const state = useTocElementState();
|
|
24
|
-
const { props: btnProps } = useTocElement(state);
|
|
25
|
-
const { headingList } = state;
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<PlateElement {...props} className="my-1">
|
|
29
|
-
<div contentEditable={false}>
|
|
30
|
-
{headingList.length > 0 ? (
|
|
31
|
-
headingList.map(item => (
|
|
32
|
-
<Button
|
|
33
|
-
aria-current
|
|
34
|
-
className={headingItemVariants({ depth: item.depth as any })}
|
|
35
|
-
key={item.id}
|
|
36
|
-
onClick={e => btnProps.onClick(e, item, 'smooth')}
|
|
37
|
-
variant="ghost">
|
|
38
|
-
{item.title}
|
|
39
|
-
</Button>
|
|
40
|
-
))
|
|
41
|
-
) : (
|
|
42
|
-
<div
|
|
43
|
-
className="cursor-text select-none px-1 py-[3px] text-muted-foreground/80 text-sm"
|
|
44
|
-
onClick={() => {
|
|
45
|
-
editor
|
|
46
|
-
.getApi(BlockSelectionPlugin)
|
|
47
|
-
.blockSelection.set(element.id as string);
|
|
48
|
-
}}
|
|
49
|
-
role="button">
|
|
50
|
-
Add headings to display the table of contents.
|
|
51
|
-
</div>
|
|
52
|
-
)}
|
|
53
|
-
</div>
|
|
54
|
-
{props.children}
|
|
55
|
-
</PlateElement>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useTocSideBar, useTocSideBarState } from '@platejs/toc/react';
|
|
4
|
-
import { cva } from 'class-variance-authority';
|
|
5
|
-
|
|
6
|
-
import { Button } from './button';
|
|
7
|
-
|
|
8
|
-
const headingItemVariants = cva(
|
|
9
|
-
'block w-full cursor-pointer truncate rounded-none px-1 py-1 text-left text-muted-foreground text-sm transition-colors hover:bg-accent',
|
|
10
|
-
{
|
|
11
|
-
variants: {
|
|
12
|
-
depth: {
|
|
13
|
-
1: 'pl-1 font-medium',
|
|
14
|
-
2: 'pl-4',
|
|
15
|
-
3: 'pl-7'
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export function TocSidebar() {
|
|
22
|
-
const state = useTocSideBarState({ open: true });
|
|
23
|
-
const { headingList } = state;
|
|
24
|
-
const { navProps } = useTocSideBar(state);
|
|
25
|
-
|
|
26
|
-
if (headingList.length === 0) return null;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<nav {...navProps} className="sticky top-20 hidden w-[200px] shrink-0 lg:block">
|
|
30
|
-
<div className="flex flex-col gap-0.5">
|
|
31
|
-
{headingList.map((item: any) => (
|
|
32
|
-
<Button
|
|
33
|
-
className={headingItemVariants({ depth: item.depth as any })}
|
|
34
|
-
key={item.id}
|
|
35
|
-
onClick={(e) => {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
const el = document.getElementById(item.id);
|
|
38
|
-
|
|
39
|
-
el?.scrollIntoView({ behavior: 'smooth' });
|
|
40
|
-
}}
|
|
41
|
-
variant="ghost">
|
|
42
|
-
{item.title}
|
|
43
|
-
</Button>
|
|
44
|
-
))}
|
|
45
|
-
</div>
|
|
46
|
-
</nav>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { ChevronRightIcon } from 'lucide-react';
|
|
3
|
-
import { SlateElement, type SlateElementProps } from 'platejs/static';
|
|
4
|
-
|
|
5
|
-
export function ToggleElementStatic(props: SlateElementProps) {
|
|
6
|
-
return (
|
|
7
|
-
<SlateElement {...props} className="mb-1 pl-6">
|
|
8
|
-
<div>
|
|
9
|
-
<span
|
|
10
|
-
className="absolute top-0.5 left-0 flex cursor-pointer select-none items-center justify-center rounded-sm p-px transition-bg-ease hover:bg-slate-200"
|
|
11
|
-
contentEditable={false}>
|
|
12
|
-
<ChevronRightIcon className="rotate-0 transition-transform duration-75" />
|
|
13
|
-
</span>
|
|
14
|
-
{props.children}
|
|
15
|
-
</div>
|
|
16
|
-
</SlateElement>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useToggleButton, useToggleButtonState } from '@platejs/toggle/react';
|
|
2
|
-
import { ChevronRightIcon } from 'lucide-react';
|
|
3
|
-
import {
|
|
4
|
-
PlateElement,
|
|
5
|
-
type PlateElementProps,
|
|
6
|
-
useElement
|
|
7
|
-
} from 'platejs/react';
|
|
8
|
-
|
|
9
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
10
|
-
|
|
11
|
-
export function ToggleElement(props: PlateElementProps) {
|
|
12
|
-
const element = useElement();
|
|
13
|
-
const state = useToggleButtonState(element.id as string);
|
|
14
|
-
const { buttonProps, open } = useToggleButton(state);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<PlateElement {...props} className="mb-1 pl-6">
|
|
18
|
-
<div>
|
|
19
|
-
<span
|
|
20
|
-
className="absolute top-0.5 left-0 flex cursor-pointer select-none items-center justify-center rounded-sm p-px transition-bg-ease hover:bg-slate-200"
|
|
21
|
-
contentEditable={false}
|
|
22
|
-
{...buttonProps}>
|
|
23
|
-
<ChevronRightIcon
|
|
24
|
-
className={cn(
|
|
25
|
-
'transition-transform duration-75',
|
|
26
|
-
open ? 'rotate-90' : 'rotate-0'
|
|
27
|
-
)} />
|
|
28
|
-
</span>
|
|
29
|
-
{props.children}
|
|
30
|
-
</div>
|
|
31
|
-
</PlateElement>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ComponentProps } from 'react';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
useToggleToolbarButton,
|
|
7
|
-
useToggleToolbarButtonState
|
|
8
|
-
} from '@platejs/toggle/react';
|
|
9
|
-
import { ListCollapseIcon } from 'lucide-react';
|
|
10
|
-
|
|
11
|
-
import { ToolbarButton } from './toolbar';
|
|
12
|
-
|
|
13
|
-
export function ToggleToolbarButton(
|
|
14
|
-
props: ComponentProps<typeof ToolbarButton>
|
|
15
|
-
) {
|
|
16
|
-
const state = useToggleToolbarButtonState();
|
|
17
|
-
const { props: buttonProps } = useToggleToolbarButton(state);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<ToolbarButton {...props} {...buttonProps} tooltip="Toggle">
|
|
21
|
-
<ListCollapseIcon />
|
|
22
|
-
</ToolbarButton>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useEffect, useState, type ComponentProps, type ComponentPropsWithoutRef, type ElementType, type ReactNode
|
|
5
|
-
} from 'react';
|
|
6
|
-
|
|
7
|
-
import { type VariantProps, cva } from 'class-variance-authority';
|
|
8
|
-
import { ChevronDown } from 'lucide-react';
|
|
9
|
-
import { Toolbar as ToolbarPrimitive, Tooltip as TooltipPrimitive } from 'radix-ui';
|
|
10
|
-
|
|
11
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
DropdownMenuLabel,
|
|
15
|
-
DropdownMenuRadioGroup,
|
|
16
|
-
DropdownMenuSeparator
|
|
17
|
-
} from './dropdown-menu';
|
|
18
|
-
import { Separator } from './separator';
|
|
19
|
-
import { Tooltip, TooltipProvider, TooltipTrigger } from './tooltip';
|
|
20
|
-
|
|
21
|
-
export function Toolbar({
|
|
22
|
-
className,
|
|
23
|
-
...props
|
|
24
|
-
}: ComponentProps<typeof ToolbarPrimitive.Root>) {
|
|
25
|
-
return (
|
|
26
|
-
<ToolbarPrimitive.Root
|
|
27
|
-
className={cn('relative flex flex-nowrap select-none items-center gap-1', className)}
|
|
28
|
-
{...props} />
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function ToolbarToggleGroup({
|
|
33
|
-
className,
|
|
34
|
-
...props
|
|
35
|
-
}: ComponentProps<typeof ToolbarPrimitive.ToolbarToggleGroup>) {
|
|
36
|
-
return (
|
|
37
|
-
<ToolbarPrimitive.ToolbarToggleGroup
|
|
38
|
-
className={cn('flex items-center', className)}
|
|
39
|
-
{...props} />
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function ToolbarLink({
|
|
44
|
-
className,
|
|
45
|
-
...props
|
|
46
|
-
}: ComponentProps<typeof ToolbarPrimitive.Link>) {
|
|
47
|
-
return (
|
|
48
|
-
<ToolbarPrimitive.Link
|
|
49
|
-
className={cn('font-medium underline underline-offset-4', className)}
|
|
50
|
-
{...props} />
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function ToolbarSeparator({
|
|
55
|
-
className,
|
|
56
|
-
...props
|
|
57
|
-
}: ComponentProps<typeof ToolbarPrimitive.Separator>) {
|
|
58
|
-
return (
|
|
59
|
-
<ToolbarPrimitive.Separator
|
|
60
|
-
className={cn('mx-2 my-1 w-px shrink-0 bg-border', className)}
|
|
61
|
-
{...props} />
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// From toggleVariants
|
|
66
|
-
export const toolbarButtonVariants = cva(
|
|
67
|
-
"inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium text-sm outline-none transition-[color,box-shadow] hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-checked:bg-accent aria-checked:text-accent-foreground aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
68
|
-
{
|
|
69
|
-
defaultVariants: {
|
|
70
|
-
size: 'default',
|
|
71
|
-
variant: 'default'
|
|
72
|
-
},
|
|
73
|
-
variants: {
|
|
74
|
-
size: {
|
|
75
|
-
default: 'h-9 min-w-9 px-2',
|
|
76
|
-
lg: 'h-10 min-w-10 px-2.5',
|
|
77
|
-
sm: 'h-8 min-w-8 px-1.5',
|
|
78
|
-
none: ''
|
|
79
|
-
},
|
|
80
|
-
variant: {
|
|
81
|
-
default: 'bg-transparent',
|
|
82
|
-
outline:
|
|
83
|
-
'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',
|
|
84
|
-
media:
|
|
85
|
-
'no-focus-ring m-0 h-auto rounded-none not-last:border-r not-last:border-r-white/20 bg-black/20 px-1.5 py-1 text-white hover:bg-white/5 focus:bg-white/5 [&_svg]:size-[14px] [&_svg]:text-white'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const dropdownArrowVariants = cva(
|
|
92
|
-
cn(
|
|
93
|
-
'inline-flex items-center justify-center rounded-r-md font-medium text-foreground text-sm transition-colors disabled:pointer-events-none disabled:opacity-50'
|
|
94
|
-
),
|
|
95
|
-
{
|
|
96
|
-
defaultVariants: {
|
|
97
|
-
size: 'sm',
|
|
98
|
-
variant: 'default'
|
|
99
|
-
},
|
|
100
|
-
variants: {
|
|
101
|
-
size: {
|
|
102
|
-
default: 'h-9 w-6',
|
|
103
|
-
lg: 'h-10 w-8',
|
|
104
|
-
sm: 'h-8 w-4'
|
|
105
|
-
},
|
|
106
|
-
variant: {
|
|
107
|
-
default:
|
|
108
|
-
'bg-transparent hover:bg-muted hover:text-muted-foreground aria-checked:bg-accent aria-checked:text-accent-foreground',
|
|
109
|
-
outline:
|
|
110
|
-
'border border-input border-l-0 bg-transparent hover:bg-accent hover:text-accent-foreground'
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
type ToolbarButtonProps = {
|
|
117
|
-
isDropdown?: boolean;
|
|
118
|
-
pressed?: boolean;
|
|
119
|
-
} & Omit<
|
|
120
|
-
ComponentPropsWithoutRef<typeof ToolbarToggleItem>,
|
|
121
|
-
'asChild' | 'value'
|
|
122
|
-
>
|
|
123
|
-
& VariantProps<typeof toolbarButtonVariants>;
|
|
124
|
-
|
|
125
|
-
export const ToolbarButton = withTooltip(({
|
|
126
|
-
children,
|
|
127
|
-
className,
|
|
128
|
-
isDropdown,
|
|
129
|
-
pressed,
|
|
130
|
-
size = 'sm',
|
|
131
|
-
variant,
|
|
132
|
-
...props
|
|
133
|
-
}: ToolbarButtonProps) => {
|
|
134
|
-
return typeof pressed === 'boolean' ? (
|
|
135
|
-
<ToolbarToggleGroup disabled={props.disabled} value="single" type="single">
|
|
136
|
-
<ToolbarToggleItem
|
|
137
|
-
className={cn(
|
|
138
|
-
toolbarButtonVariants({
|
|
139
|
-
size,
|
|
140
|
-
variant
|
|
141
|
-
}),
|
|
142
|
-
isDropdown && 'justify-between gap-1 pr-1',
|
|
143
|
-
className
|
|
144
|
-
)}
|
|
145
|
-
value={pressed ? 'single' : ''}
|
|
146
|
-
{...props}>
|
|
147
|
-
{isDropdown ? (
|
|
148
|
-
<>
|
|
149
|
-
<div className="flex flex-1 items-center gap-2 whitespace-nowrap">
|
|
150
|
-
{children}
|
|
151
|
-
</div>
|
|
152
|
-
<div>
|
|
153
|
-
<ChevronDown
|
|
154
|
-
className="size-3.5 text-muted-foreground"
|
|
155
|
-
data-icon />
|
|
156
|
-
</div>
|
|
157
|
-
</>
|
|
158
|
-
) : (
|
|
159
|
-
children
|
|
160
|
-
)}
|
|
161
|
-
</ToolbarToggleItem>
|
|
162
|
-
</ToolbarToggleGroup>
|
|
163
|
-
) : (
|
|
164
|
-
<ToolbarPrimitive.Button
|
|
165
|
-
className={cn(
|
|
166
|
-
toolbarButtonVariants({
|
|
167
|
-
size,
|
|
168
|
-
variant
|
|
169
|
-
}),
|
|
170
|
-
isDropdown && 'pr-1',
|
|
171
|
-
className
|
|
172
|
-
)}
|
|
173
|
-
{...props}>
|
|
174
|
-
{children}
|
|
175
|
-
</ToolbarPrimitive.Button>
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
export function ToolbarSplitButton({
|
|
180
|
-
className,
|
|
181
|
-
...props
|
|
182
|
-
}: ComponentPropsWithoutRef<typeof ToolbarButton>) {
|
|
183
|
-
return (
|
|
184
|
-
<ToolbarButton
|
|
185
|
-
className={cn('group flex gap-0 px-0 hover:bg-transparent', className)}
|
|
186
|
-
{...props} />
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
type ToolbarSplitButtonPrimaryProps = Omit<
|
|
191
|
-
ComponentPropsWithoutRef<typeof ToolbarToggleItem>,
|
|
192
|
-
'value'
|
|
193
|
-
>
|
|
194
|
-
& VariantProps<typeof toolbarButtonVariants>;
|
|
195
|
-
|
|
196
|
-
export function ToolbarSplitButtonPrimary({
|
|
197
|
-
children,
|
|
198
|
-
className,
|
|
199
|
-
size = 'sm',
|
|
200
|
-
variant,
|
|
201
|
-
...props
|
|
202
|
-
}: ToolbarSplitButtonPrimaryProps) {
|
|
203
|
-
return (
|
|
204
|
-
<span
|
|
205
|
-
className={cn(
|
|
206
|
-
toolbarButtonVariants({
|
|
207
|
-
size,
|
|
208
|
-
variant
|
|
209
|
-
}),
|
|
210
|
-
'rounded-r-none',
|
|
211
|
-
'group-data-[pressed=true]:bg-accent group-data-[pressed=true]:text-accent-foreground',
|
|
212
|
-
className
|
|
213
|
-
)}
|
|
214
|
-
{...props}>
|
|
215
|
-
{children}
|
|
216
|
-
</span>
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export function ToolbarSplitButtonSecondary({
|
|
221
|
-
className,
|
|
222
|
-
size,
|
|
223
|
-
variant,
|
|
224
|
-
...props
|
|
225
|
-
}: ComponentPropsWithoutRef<'span'>
|
|
226
|
-
& VariantProps<typeof dropdownArrowVariants>) {
|
|
227
|
-
return (
|
|
228
|
-
<span
|
|
229
|
-
className={cn(
|
|
230
|
-
dropdownArrowVariants({
|
|
231
|
-
size,
|
|
232
|
-
variant
|
|
233
|
-
}),
|
|
234
|
-
'group-data-[pressed=true]:bg-accent group-data-[pressed=true]:text-accent-foreground',
|
|
235
|
-
className
|
|
236
|
-
)}
|
|
237
|
-
onClick={e => e.stopPropagation()}
|
|
238
|
-
role="button"
|
|
239
|
-
{...props}>
|
|
240
|
-
<ChevronDown className="size-3.5 text-muted-foreground" data-icon />
|
|
241
|
-
</span>
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export function ToolbarToggleItem({
|
|
246
|
-
className,
|
|
247
|
-
size = 'sm',
|
|
248
|
-
variant,
|
|
249
|
-
...props
|
|
250
|
-
}: ComponentProps<typeof ToolbarPrimitive.ToggleItem>
|
|
251
|
-
& VariantProps<typeof toolbarButtonVariants>) {
|
|
252
|
-
return (
|
|
253
|
-
<ToolbarPrimitive.ToggleItem
|
|
254
|
-
className={cn(toolbarButtonVariants({ size, variant }), className)}
|
|
255
|
-
{...props} />
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export function ToolbarGroup({
|
|
260
|
-
children,
|
|
261
|
-
className
|
|
262
|
-
}: ComponentProps<'div'>) {
|
|
263
|
-
return (
|
|
264
|
-
<div
|
|
265
|
-
className={cn(
|
|
266
|
-
'group/toolbar-group',
|
|
267
|
-
'relative hidden has-[button]:flex flex-shrink-0',
|
|
268
|
-
className
|
|
269
|
-
)}>
|
|
270
|
-
<div className="flex items-center flex-shrink-0">{children}</div>
|
|
271
|
-
|
|
272
|
-
<div className="group-last/toolbar-group:hidden! mx-1.5 py-0.5">
|
|
273
|
-
<Separator orientation="vertical" />
|
|
274
|
-
</div>
|
|
275
|
-
</div>
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
type TooltipProps<T extends ElementType> = {
|
|
280
|
-
tooltip?: ReactNode;
|
|
281
|
-
tooltipContentProps?: Omit<
|
|
282
|
-
ComponentPropsWithoutRef<typeof TooltipContent>,
|
|
283
|
-
'children'
|
|
284
|
-
>;
|
|
285
|
-
tooltipProps?: Omit<
|
|
286
|
-
ComponentPropsWithoutRef<typeof Tooltip>,
|
|
287
|
-
'children'
|
|
288
|
-
>;
|
|
289
|
-
tooltipTriggerProps?: ComponentPropsWithoutRef<typeof TooltipTrigger>;
|
|
290
|
-
} & ComponentProps<T>;
|
|
291
|
-
|
|
292
|
-
function withTooltip<T extends ElementType>(Component: T) {
|
|
293
|
-
return function ExtendComponent({
|
|
294
|
-
tooltip,
|
|
295
|
-
tooltipContentProps,
|
|
296
|
-
tooltipProps,
|
|
297
|
-
tooltipTriggerProps,
|
|
298
|
-
...props
|
|
299
|
-
}: TooltipProps<T>) {
|
|
300
|
-
const [mounted, setMounted] = useState(false);
|
|
301
|
-
|
|
302
|
-
useEffect(() => {
|
|
303
|
-
setMounted(true);
|
|
304
|
-
}, []);
|
|
305
|
-
|
|
306
|
-
const component = <Component {...(props as ComponentProps<T>)} />;
|
|
307
|
-
|
|
308
|
-
if (tooltip && mounted) {
|
|
309
|
-
return (
|
|
310
|
-
<TooltipProvider>
|
|
311
|
-
<Tooltip {...tooltipProps}>
|
|
312
|
-
<TooltipTrigger asChild {...tooltipTriggerProps}>
|
|
313
|
-
{component}
|
|
314
|
-
</TooltipTrigger>
|
|
315
|
-
|
|
316
|
-
<TooltipContent {...tooltipContentProps}>{tooltip}</TooltipContent>
|
|
317
|
-
</Tooltip>
|
|
318
|
-
</TooltipProvider>
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
return component;
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function TooltipContent({
|
|
327
|
-
children,
|
|
328
|
-
className,
|
|
329
|
-
sideOffset = 4,
|
|
330
|
-
...props
|
|
331
|
-
}: ComponentProps<typeof TooltipPrimitive.Content>) {
|
|
332
|
-
return (
|
|
333
|
-
<TooltipPrimitive.Portal>
|
|
334
|
-
<TooltipPrimitive.Content
|
|
335
|
-
className={cn(
|
|
336
|
-
'z-50 w-fit origin-(--radix-tooltip-content-transform-origin) text-balance rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs',
|
|
337
|
-
className
|
|
338
|
-
)}
|
|
339
|
-
data-slot="tooltip-content"
|
|
340
|
-
sideOffset={sideOffset}
|
|
341
|
-
{...props}>
|
|
342
|
-
{children}
|
|
343
|
-
</TooltipPrimitive.Content>
|
|
344
|
-
</TooltipPrimitive.Portal>
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
export function ToolbarMenuGroup({
|
|
349
|
-
children,
|
|
350
|
-
className,
|
|
351
|
-
label,
|
|
352
|
-
...props
|
|
353
|
-
}: ComponentProps<typeof DropdownMenuRadioGroup> & { label?: string }) {
|
|
354
|
-
return (
|
|
355
|
-
<>
|
|
356
|
-
<DropdownMenuSeparator
|
|
357
|
-
className={cn(
|
|
358
|
-
'hidden',
|
|
359
|
-
'mb-0 shrink-0 peer-has-[[role=menuitem]]/menu-group:block peer-has-[[role=menuitemradio]]/menu-group:block peer-has-[[role=option]]/menu-group:block'
|
|
360
|
-
)} />
|
|
361
|
-
|
|
362
|
-
<DropdownMenuRadioGroup
|
|
363
|
-
{...props}
|
|
364
|
-
className={cn(
|
|
365
|
-
'hidden',
|
|
366
|
-
'peer/menu-group group/menu-group my-1.5 has-[[role=menuitem]]:block has-[[role=menuitemradio]]:block has-[[role=option]]:block',
|
|
367
|
-
className
|
|
368
|
-
)}>
|
|
369
|
-
{label && (
|
|
370
|
-
<DropdownMenuLabel className="select-none font-semibold text-muted-foreground text-xs">
|
|
371
|
-
{label}
|
|
372
|
-
</DropdownMenuLabel>
|
|
373
|
-
)}
|
|
374
|
-
{children}
|
|
375
|
-
</DropdownMenuRadioGroup>
|
|
376
|
-
</>
|
|
377
|
-
);
|
|
378
|
-
}
|