@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,84 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties } from 'react';
|
|
2
|
-
|
|
3
|
-
import { type TTableCellElement, type TTableElement } from 'platejs';
|
|
4
|
-
|
|
5
|
-
import { BaseTablePlugin } from '@platejs/table';
|
|
6
|
-
|
|
7
|
-
import { SlateElement, type SlateElementProps } from 'platejs/static';
|
|
8
|
-
|
|
9
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
10
|
-
|
|
11
|
-
export function TableElementStatic(props: SlateElementProps<TTableElement>) {
|
|
12
|
-
const { disableMarginLeft } = props.editor.getOptions(BaseTablePlugin);
|
|
13
|
-
const marginLeft = disableMarginLeft ? 0 : props.element.marginLeft;
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<SlateElement
|
|
17
|
-
{...props}
|
|
18
|
-
className="overflow-x-auto py-5"
|
|
19
|
-
style={{ paddingLeft: marginLeft }}>
|
|
20
|
-
<div className="group/table relative w-fit">
|
|
21
|
-
<table className="mr-0 ml-px table h-px table-fixed border-collapse">
|
|
22
|
-
<tbody className="min-w-full">{props.children}</tbody>
|
|
23
|
-
</table>
|
|
24
|
-
</div>
|
|
25
|
-
</SlateElement>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function TableRowElementStatic(props: SlateElementProps) {
|
|
30
|
-
return <SlateElement {...props} as="tr" className="h-full" />;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function TableCellElementStatic({
|
|
34
|
-
isHeader,
|
|
35
|
-
...props
|
|
36
|
-
}: SlateElementProps<TTableCellElement> & {
|
|
37
|
-
isHeader?: boolean;
|
|
38
|
-
}) {
|
|
39
|
-
const { editor, element } = props;
|
|
40
|
-
const { api } = editor.getPlugin(BaseTablePlugin);
|
|
41
|
-
|
|
42
|
-
const { minHeight, width } = api.table.getCellSize({ element });
|
|
43
|
-
const borders = api.table.getCellBorders({ element });
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<SlateElement
|
|
47
|
-
{...props}
|
|
48
|
-
as={isHeader ? 'th' : 'td'}
|
|
49
|
-
attributes={{
|
|
50
|
-
...props.attributes,
|
|
51
|
-
colSpan: api.table.getColSpan(element),
|
|
52
|
-
rowSpan: api.table.getRowSpan(element)
|
|
53
|
-
}}
|
|
54
|
-
className={cn(
|
|
55
|
-
'h-full overflow-visible border-none bg-background p-0',
|
|
56
|
-
element.background ? 'bg-(--cellBackground)' : 'bg-background',
|
|
57
|
-
isHeader && 'text-left font-normal *:m-0',
|
|
58
|
-
'before:size-full',
|
|
59
|
-
"before:absolute before:box-border before:select-none before:content-['']",
|
|
60
|
-
'before:border before:border-border',
|
|
61
|
-
borders.bottom?.size && 'before:border-b before:border-b-border',
|
|
62
|
-
borders.right?.size && 'before:border-r before:border-r-border',
|
|
63
|
-
borders.left?.size && 'before:border-l before:border-l-border',
|
|
64
|
-
borders.top?.size && 'before:border-t before:border-t-border'
|
|
65
|
-
)}
|
|
66
|
-
style={
|
|
67
|
-
{
|
|
68
|
-
'--cellBackground': element.background,
|
|
69
|
-
maxWidth: width || 240,
|
|
70
|
-
minWidth: width || 120
|
|
71
|
-
} as CSSProperties
|
|
72
|
-
}>
|
|
73
|
-
<div
|
|
74
|
-
className="relative z-20 box-border h-full px-4 py-2"
|
|
75
|
-
style={{ minHeight }}>
|
|
76
|
-
{props.children}
|
|
77
|
-
</div>
|
|
78
|
-
</SlateElement>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function TableCellHeaderElementStatic(props: SlateElementProps) {
|
|
83
|
-
return <TableCellElementStatic {...props} isHeader />;
|
|
84
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type CSSProperties, type ComponentProps } from 'react';
|
|
4
|
-
|
|
5
|
-
import { ResizeHandle } from '@platejs/resizable';
|
|
6
|
-
import { useBlockSelected } from '@platejs/selection/react';
|
|
7
|
-
import {
|
|
8
|
-
TablePlugin,
|
|
9
|
-
TableProvider,
|
|
10
|
-
useTableCellElement,
|
|
11
|
-
useTableCellElementResizable,
|
|
12
|
-
useTableElement
|
|
13
|
-
} from '@platejs/table/react';
|
|
14
|
-
import { cva } from 'class-variance-authority';
|
|
15
|
-
import { PlusIcon } from 'lucide-react';
|
|
16
|
-
import { KEYS, type TTableCellElement } from 'platejs';
|
|
17
|
-
import {
|
|
18
|
-
PlateElement,
|
|
19
|
-
type PlateElementProps,
|
|
20
|
-
useEditorPlugin,
|
|
21
|
-
useElementSelector,
|
|
22
|
-
useReadOnly,
|
|
23
|
-
useSelected,
|
|
24
|
-
withHOC
|
|
25
|
-
} from 'platejs/react';
|
|
26
|
-
|
|
27
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
28
|
-
|
|
29
|
-
import { blockSelectionVariants } from './block-selection';
|
|
30
|
-
|
|
31
|
-
import { Button } from './button';
|
|
32
|
-
|
|
33
|
-
export const TableElement = withHOC(
|
|
34
|
-
TableProvider,
|
|
35
|
-
(props: PlateElementProps) => {
|
|
36
|
-
const { editor, element } = props;
|
|
37
|
-
const { tf } = useEditorPlugin(TablePlugin);
|
|
38
|
-
const readOnly = useReadOnly();
|
|
39
|
-
const {
|
|
40
|
-
isSelectingCell,
|
|
41
|
-
marginLeft,
|
|
42
|
-
props: tableProps
|
|
43
|
-
} = useTableElement();
|
|
44
|
-
|
|
45
|
-
const isSelectingTable = useBlockSelected(props.element.id as string);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<PlateElement
|
|
49
|
-
{...props}
|
|
50
|
-
className="overflow-x-auto py-5"
|
|
51
|
-
style={{ paddingLeft: marginLeft }}>
|
|
52
|
-
<div className="group/table relative w-fit">
|
|
53
|
-
<table
|
|
54
|
-
className={cn(
|
|
55
|
-
'mr-0 ml-px table h-px table-fixed border-collapse',
|
|
56
|
-
isSelectingCell && 'selection:bg-transparent'
|
|
57
|
-
)}
|
|
58
|
-
{...tableProps}>
|
|
59
|
-
<tbody className="min-w-full">{props.children}</tbody>
|
|
60
|
-
</table>
|
|
61
|
-
|
|
62
|
-
{!readOnly && (
|
|
63
|
-
<>
|
|
64
|
-
<div
|
|
65
|
-
className={cn(
|
|
66
|
-
'absolute inset-x-0 bottom-[-18px] flex flex-row opacity-0 transition-opacity hover:opacity-100',
|
|
67
|
-
'group-has-[tr:last-child:hover]/table:opacity-100 max-sm:group-has-[tr[data-selected]:last-child]/table:opacity-100'
|
|
68
|
-
)}>
|
|
69
|
-
<Button
|
|
70
|
-
className="flex h-4 w-full grow items-center justify-center bg-muted"
|
|
71
|
-
onClick={() => tf.insert.tableRow({ at: editor.api.findPath(element) })}
|
|
72
|
-
onMouseDown={e => e.preventDefault()}
|
|
73
|
-
size="none"
|
|
74
|
-
tooltip="Add a new row"
|
|
75
|
-
tooltipContentProps={{ side: 'bottom' }}
|
|
76
|
-
variant="ghost">
|
|
77
|
-
<PlusIcon className="!size-3.5 text-muted-foreground" />
|
|
78
|
-
</Button>
|
|
79
|
-
</div>
|
|
80
|
-
|
|
81
|
-
<div
|
|
82
|
-
className={cn(
|
|
83
|
-
'absolute inset-y-0 right-[-18px] flex opacity-0 transition-opacity hover:opacity-100',
|
|
84
|
-
'group-has-[td:last-child:hover,th:last-child:hover]/table:opacity-100 max-sm:group-has-[td[data-selected]:last-child,th[data-selected]:last-child]/table:opacity-100'
|
|
85
|
-
)}>
|
|
86
|
-
<Button
|
|
87
|
-
className="flex h-full w-4 grow items-center justify-center bg-muted"
|
|
88
|
-
onClick={() => tf.insert.tableColumn({
|
|
89
|
-
at: editor.api.findPath(element)
|
|
90
|
-
})}
|
|
91
|
-
onMouseDown={e => e.preventDefault()}
|
|
92
|
-
size="none"
|
|
93
|
-
tooltip="Add a new column"
|
|
94
|
-
tooltipContentProps={{ side: 'bottom' }}
|
|
95
|
-
variant="ghost">
|
|
96
|
-
<PlusIcon className="!size-3.5 text-muted-foreground" />
|
|
97
|
-
</Button>
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
<div
|
|
101
|
-
className={cn(
|
|
102
|
-
'absolute right-[-18px] bottom-[-18px] flex flex-row opacity-0 transition-opacity hover:opacity-100',
|
|
103
|
-
'group-has-[td:last-child:hover,th:last-child:hover]/table:group-has-[tr:last-child:hover]/table:opacity-100 max-sm:group-has-[td[data-selected]:last-child,th[data-selected]:last-child]/table:group-has-[tr[data-selected]:last-child]/table:opacity-100'
|
|
104
|
-
)}>
|
|
105
|
-
<Button
|
|
106
|
-
className="flex size-4 items-center justify-center rounded-full bg-muted"
|
|
107
|
-
onClick={() => {
|
|
108
|
-
editor.tf.withoutNormalizing(() => {
|
|
109
|
-
tf.insert.tableRow({ at: editor.api.findPath(element) });
|
|
110
|
-
tf.insert.tableColumn({
|
|
111
|
-
at: editor.api.findPath(element)
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
}}
|
|
115
|
-
onMouseDown={e => e.preventDefault()}
|
|
116
|
-
size="none"
|
|
117
|
-
tooltip="Add a new row and column"
|
|
118
|
-
tooltipContentProps={{ side: 'bottom' }}
|
|
119
|
-
variant="ghost">
|
|
120
|
-
<PlusIcon className="!size-3.5 text-muted-foreground" />
|
|
121
|
-
</Button>
|
|
122
|
-
</div>
|
|
123
|
-
</>
|
|
124
|
-
)}
|
|
125
|
-
|
|
126
|
-
{isSelectingTable && (
|
|
127
|
-
<div className={blockSelectionVariants()} contentEditable={false} />
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
</PlateElement>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
export function TableRowElement(props: PlateElementProps) {
|
|
136
|
-
const selected = useSelected();
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<PlateElement
|
|
140
|
-
{...props}
|
|
141
|
-
as="tr"
|
|
142
|
-
className="h-full"
|
|
143
|
-
data-selected={selected ? 'true' : undefined} />
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function TableCellElement({
|
|
148
|
-
isHeader,
|
|
149
|
-
...props
|
|
150
|
-
}: PlateElementProps<TTableCellElement> & {
|
|
151
|
-
isHeader?: boolean;
|
|
152
|
-
}) {
|
|
153
|
-
const { api } = useEditorPlugin(TablePlugin);
|
|
154
|
-
const readOnly = useReadOnly();
|
|
155
|
-
const { element } = props;
|
|
156
|
-
|
|
157
|
-
const rowId = useElementSelector(([node]) => node.id as string, [], {
|
|
158
|
-
key: KEYS.tr
|
|
159
|
-
});
|
|
160
|
-
const isSelectingRow = useBlockSelected(rowId);
|
|
161
|
-
|
|
162
|
-
const {
|
|
163
|
-
borders,
|
|
164
|
-
colIndex,
|
|
165
|
-
colSpan,
|
|
166
|
-
isSelectingCell,
|
|
167
|
-
minHeight,
|
|
168
|
-
rowIndex,
|
|
169
|
-
selected,
|
|
170
|
-
width
|
|
171
|
-
} = useTableCellElement();
|
|
172
|
-
|
|
173
|
-
const {
|
|
174
|
-
bottomProps, hiddenLeft, leftProps, rightProps
|
|
175
|
-
}
|
|
176
|
-
= useTableCellElementResizable({
|
|
177
|
-
colIndex,
|
|
178
|
-
colSpan,
|
|
179
|
-
rowIndex
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
<PlateElement
|
|
184
|
-
{...props}
|
|
185
|
-
as={isHeader ? 'th' : 'td'}
|
|
186
|
-
attributes={{
|
|
187
|
-
...props.attributes,
|
|
188
|
-
colSpan: api.table.getColSpan(element),
|
|
189
|
-
rowSpan: api.table.getRowSpan(element)
|
|
190
|
-
}}
|
|
191
|
-
className={cn(
|
|
192
|
-
'h-full overflow-visible border-none bg-background p-0',
|
|
193
|
-
element.background ? 'bg-(--cellBackground)' : 'bg-background',
|
|
194
|
-
isHeader && 'text-left *:m-0',
|
|
195
|
-
'before:size-full',
|
|
196
|
-
selected && 'before:z-10 before:bg-muted',
|
|
197
|
-
"before:absolute before:box-border before:select-none before:content-['']",
|
|
198
|
-
borders.bottom?.size && 'before:border-b before:border-b-border',
|
|
199
|
-
borders.right?.size && 'before:border-r before:border-r-border',
|
|
200
|
-
borders.left?.size && 'before:border-l before:border-l-border',
|
|
201
|
-
borders.top?.size && 'before:border-t before:border-t-border'
|
|
202
|
-
)}
|
|
203
|
-
style={
|
|
204
|
-
{
|
|
205
|
-
'--cellBackground': element.background,
|
|
206
|
-
maxWidth: width || 240,
|
|
207
|
-
minWidth: width || 120
|
|
208
|
-
} as CSSProperties
|
|
209
|
-
}>
|
|
210
|
-
<div
|
|
211
|
-
className="relative z-20 box-border h-full px-4 py-2"
|
|
212
|
-
style={{ minHeight }}>
|
|
213
|
-
{props.children}
|
|
214
|
-
</div>
|
|
215
|
-
|
|
216
|
-
{!isSelectingCell && (
|
|
217
|
-
<div
|
|
218
|
-
className="group absolute top-0 size-full select-none"
|
|
219
|
-
contentEditable={false}
|
|
220
|
-
suppressContentEditableWarning={true}>
|
|
221
|
-
{!readOnly && (
|
|
222
|
-
<>
|
|
223
|
-
<ResizeHandle
|
|
224
|
-
{...rightProps}
|
|
225
|
-
className="-top-2 -right-1 h-[calc(100%_+_8px)] w-2"
|
|
226
|
-
data-col={colIndex} />
|
|
227
|
-
<ResizeHandle {...bottomProps} className="-bottom-1 h-2" />
|
|
228
|
-
{!hiddenLeft && (
|
|
229
|
-
<ResizeHandle
|
|
230
|
-
{...leftProps}
|
|
231
|
-
className="-left-1 top-0 w-2"
|
|
232
|
-
data-resizer-left={colIndex === 0 ? 'true' : undefined} />
|
|
233
|
-
)}
|
|
234
|
-
|
|
235
|
-
<div
|
|
236
|
-
className={cn(
|
|
237
|
-
'absolute top-0 z-30 hidden h-full w-1 bg-ring',
|
|
238
|
-
'right-[-1.5px]',
|
|
239
|
-
columnResizeVariants({ colIndex: colIndex as any })
|
|
240
|
-
)} />
|
|
241
|
-
{colIndex === 0 && (
|
|
242
|
-
<div
|
|
243
|
-
className={cn(
|
|
244
|
-
'absolute top-0 z-30 h-full w-1 bg-ring',
|
|
245
|
-
'left-[-1.5px]',
|
|
246
|
-
'fade-in hidden animate-in group-has-[[data-resizer-left]:hover]/table:block group-has-[[data-resizer-left][data-resizing="true"]]/table:block'
|
|
247
|
-
)} />
|
|
248
|
-
)}
|
|
249
|
-
</>
|
|
250
|
-
)}
|
|
251
|
-
</div>
|
|
252
|
-
)}
|
|
253
|
-
|
|
254
|
-
{isSelectingRow && (
|
|
255
|
-
<div className={blockSelectionVariants()} contentEditable={false} />
|
|
256
|
-
)}
|
|
257
|
-
</PlateElement>
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function TableCellHeaderElement(
|
|
262
|
-
props: ComponentProps<typeof TableCellElement>
|
|
263
|
-
) {
|
|
264
|
-
return <TableCellElement {...props} isHeader />;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const columnResizeVariants = cva('fade-in hidden animate-in', {
|
|
268
|
-
variants: {
|
|
269
|
-
colIndex: {
|
|
270
|
-
0: 'group-has-[[data-col="0"]:hover]/table:block group-has-[[data-col="0"][data-resizing="true"]]/table:block',
|
|
271
|
-
1: 'group-has-[[data-col="1"]:hover]/table:block group-has-[[data-col="1"][data-resizing="true"]]/table:block',
|
|
272
|
-
2: 'group-has-[[data-col="2"]:hover]/table:block group-has-[[data-col="2"][data-resizing="true"]]/table:block',
|
|
273
|
-
3: 'group-has-[[data-col="3"]:hover]/table:block group-has-[[data-col="3"][data-resizing="true"]]/table:block',
|
|
274
|
-
4: 'group-has-[[data-col="4"]:hover]/table:block group-has-[[data-col="4"][data-resizing="true"]]/table:block',
|
|
275
|
-
5: 'group-has-[[data-col="5"]:hover]/table:block group-has-[[data-col="5"][data-resizing="true"]]/table:block',
|
|
276
|
-
6: 'group-has-[[data-col="6"]:hover]/table:block group-has-[[data-col="6"][data-resizing="true"]]/table:block',
|
|
277
|
-
7: 'group-has-[[data-col="7"]:hover]/table:block group-has-[[data-col="7"][data-resizing="true"]]/table:block',
|
|
278
|
-
8: 'group-has-[[data-col="8"]:hover]/table:block group-has-[[data-col="8"][data-resizing="true"]]/table:block',
|
|
279
|
-
9: 'group-has-[[data-col="9"]:hover]/table:block group-has-[[data-col="9"][data-resizing="true"]]/table:block',
|
|
280
|
-
10: 'group-has-[[data-col="10"]:hover]/table:block group-has-[[data-col="10"][data-resizing="true"]]/table:block'
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
});
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import { TablePlugin, useTableMergeState } from '@platejs/table/react';
|
|
6
|
-
import {
|
|
7
|
-
ArrowDown,
|
|
8
|
-
ArrowLeft,
|
|
9
|
-
ArrowRight,
|
|
10
|
-
ArrowUp,
|
|
11
|
-
Combine,
|
|
12
|
-
Grid3x3Icon,
|
|
13
|
-
Table,
|
|
14
|
-
Trash2Icon,
|
|
15
|
-
Ungroup,
|
|
16
|
-
XIcon
|
|
17
|
-
} from 'lucide-react';
|
|
18
|
-
import { KEYS } from 'platejs';
|
|
19
|
-
import { useEditorPlugin, useEditorSelector } from 'platejs/react';
|
|
20
|
-
|
|
21
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
DropdownMenu,
|
|
25
|
-
DropdownMenuContent,
|
|
26
|
-
DropdownMenuGroup,
|
|
27
|
-
DropdownMenuItem,
|
|
28
|
-
DropdownMenuPortal,
|
|
29
|
-
DropdownMenuSub,
|
|
30
|
-
DropdownMenuSubContent,
|
|
31
|
-
DropdownMenuSubTrigger,
|
|
32
|
-
DropdownMenuTrigger,
|
|
33
|
-
type DropdownMenuProps
|
|
34
|
-
} from './dropdown-menu';
|
|
35
|
-
|
|
36
|
-
import { ToolbarButton } from './toolbar';
|
|
37
|
-
|
|
38
|
-
export function TableToolbarButton(props: DropdownMenuProps) {
|
|
39
|
-
const tableSelected = useEditorSelector(
|
|
40
|
-
editor => editor?.api?.some({ match: { type: KEYS.table } }) ?? false,
|
|
41
|
-
[]
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const { editor, tf } = useEditorPlugin(TablePlugin);
|
|
45
|
-
const [open, setOpen] = useState(false);
|
|
46
|
-
const mergeState = useTableMergeState();
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<DropdownMenu open={open} onOpenChange={setOpen} modal={false} {...props}>
|
|
50
|
-
<DropdownMenuTrigger asChild>
|
|
51
|
-
<ToolbarButton pressed={open} tooltip="Table" isDropdown>
|
|
52
|
-
<Table />
|
|
53
|
-
</ToolbarButton>
|
|
54
|
-
</DropdownMenuTrigger>
|
|
55
|
-
|
|
56
|
-
<DropdownMenuPortal>
|
|
57
|
-
<DropdownMenuContent
|
|
58
|
-
className="flex w-[180px] min-w-0 flex-col"
|
|
59
|
-
align="start">
|
|
60
|
-
<DropdownMenuGroup>
|
|
61
|
-
<DropdownMenuSub>
|
|
62
|
-
<DropdownMenuSubTrigger className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50">
|
|
63
|
-
<Grid3x3Icon className="size-4" />
|
|
64
|
-
<span>Table</span>
|
|
65
|
-
</DropdownMenuSubTrigger>
|
|
66
|
-
<DropdownMenuSubContent className="m-0 p-0">
|
|
67
|
-
<TablePicker />
|
|
68
|
-
</DropdownMenuSubContent>
|
|
69
|
-
</DropdownMenuSub>
|
|
70
|
-
|
|
71
|
-
<DropdownMenuSub>
|
|
72
|
-
<DropdownMenuSubTrigger
|
|
73
|
-
className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
74
|
-
disabled={!tableSelected}>
|
|
75
|
-
<div className="size-4" />
|
|
76
|
-
<span>Cell</span>
|
|
77
|
-
</DropdownMenuSubTrigger>
|
|
78
|
-
<DropdownMenuSubContent>
|
|
79
|
-
<DropdownMenuItem
|
|
80
|
-
className="min-w-[180px]"
|
|
81
|
-
disabled={!mergeState.canMerge}
|
|
82
|
-
onSelect={() => {
|
|
83
|
-
tf.table.merge();
|
|
84
|
-
editor.tf.focus();
|
|
85
|
-
}}>
|
|
86
|
-
<Combine />
|
|
87
|
-
Merge cells
|
|
88
|
-
</DropdownMenuItem>
|
|
89
|
-
<DropdownMenuItem
|
|
90
|
-
className="min-w-[180px]"
|
|
91
|
-
disabled={!mergeState.canSplit}
|
|
92
|
-
onSelect={() => {
|
|
93
|
-
tf.table.split();
|
|
94
|
-
editor.tf.focus();
|
|
95
|
-
}}>
|
|
96
|
-
<Ungroup />
|
|
97
|
-
Split cell
|
|
98
|
-
</DropdownMenuItem>
|
|
99
|
-
</DropdownMenuSubContent>
|
|
100
|
-
</DropdownMenuSub>
|
|
101
|
-
|
|
102
|
-
<DropdownMenuSub>
|
|
103
|
-
<DropdownMenuSubTrigger
|
|
104
|
-
className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
105
|
-
disabled={!tableSelected}>
|
|
106
|
-
<div className="size-4" />
|
|
107
|
-
<span>Row</span>
|
|
108
|
-
</DropdownMenuSubTrigger>
|
|
109
|
-
<DropdownMenuSubContent>
|
|
110
|
-
<DropdownMenuItem
|
|
111
|
-
className="min-w-[180px]"
|
|
112
|
-
disabled={!tableSelected}
|
|
113
|
-
onSelect={() => {
|
|
114
|
-
tf.insert.tableRow({ before: true });
|
|
115
|
-
editor.tf.focus();
|
|
116
|
-
}}>
|
|
117
|
-
<ArrowUp />
|
|
118
|
-
Insert row before
|
|
119
|
-
</DropdownMenuItem>
|
|
120
|
-
<DropdownMenuItem
|
|
121
|
-
className="min-w-[180px]"
|
|
122
|
-
disabled={!tableSelected}
|
|
123
|
-
onSelect={() => {
|
|
124
|
-
tf.insert.tableRow();
|
|
125
|
-
editor.tf.focus();
|
|
126
|
-
}}>
|
|
127
|
-
<ArrowDown />
|
|
128
|
-
Insert row after
|
|
129
|
-
</DropdownMenuItem>
|
|
130
|
-
<DropdownMenuItem
|
|
131
|
-
className="min-w-[180px]"
|
|
132
|
-
disabled={!tableSelected}
|
|
133
|
-
onSelect={() => {
|
|
134
|
-
tf.remove.tableRow();
|
|
135
|
-
editor.tf.focus();
|
|
136
|
-
}}>
|
|
137
|
-
<XIcon />
|
|
138
|
-
Delete row
|
|
139
|
-
</DropdownMenuItem>
|
|
140
|
-
</DropdownMenuSubContent>
|
|
141
|
-
</DropdownMenuSub>
|
|
142
|
-
|
|
143
|
-
<DropdownMenuSub>
|
|
144
|
-
<DropdownMenuSubTrigger
|
|
145
|
-
className="gap-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
146
|
-
disabled={!tableSelected}>
|
|
147
|
-
<div className="size-4" />
|
|
148
|
-
<span>Column</span>
|
|
149
|
-
</DropdownMenuSubTrigger>
|
|
150
|
-
<DropdownMenuSubContent>
|
|
151
|
-
<DropdownMenuItem
|
|
152
|
-
className="min-w-[180px]"
|
|
153
|
-
disabled={!tableSelected}
|
|
154
|
-
onSelect={() => {
|
|
155
|
-
tf.insert.tableColumn({ before: true });
|
|
156
|
-
editor.tf.focus();
|
|
157
|
-
}}>
|
|
158
|
-
<ArrowLeft />
|
|
159
|
-
Insert column before
|
|
160
|
-
</DropdownMenuItem>
|
|
161
|
-
<DropdownMenuItem
|
|
162
|
-
className="min-w-[180px]"
|
|
163
|
-
disabled={!tableSelected}
|
|
164
|
-
onSelect={() => {
|
|
165
|
-
tf.insert.tableColumn();
|
|
166
|
-
editor.tf.focus();
|
|
167
|
-
}}>
|
|
168
|
-
<ArrowRight />
|
|
169
|
-
Insert column after
|
|
170
|
-
</DropdownMenuItem>
|
|
171
|
-
<DropdownMenuItem
|
|
172
|
-
className="min-w-[180px]"
|
|
173
|
-
disabled={!tableSelected}
|
|
174
|
-
onSelect={() => {
|
|
175
|
-
tf.remove.tableColumn();
|
|
176
|
-
editor.tf.focus();
|
|
177
|
-
}}>
|
|
178
|
-
<XIcon />
|
|
179
|
-
Delete column
|
|
180
|
-
</DropdownMenuItem>
|
|
181
|
-
</DropdownMenuSubContent>
|
|
182
|
-
</DropdownMenuSub>
|
|
183
|
-
|
|
184
|
-
<DropdownMenuItem
|
|
185
|
-
className="min-w-[180px]"
|
|
186
|
-
disabled={!tableSelected}
|
|
187
|
-
onSelect={() => {
|
|
188
|
-
tf.remove.table();
|
|
189
|
-
editor.tf.focus();
|
|
190
|
-
}}>
|
|
191
|
-
<Trash2Icon />
|
|
192
|
-
Delete table
|
|
193
|
-
</DropdownMenuItem>
|
|
194
|
-
</DropdownMenuGroup>
|
|
195
|
-
</DropdownMenuContent>
|
|
196
|
-
</DropdownMenuPortal>
|
|
197
|
-
</DropdownMenu>
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function TablePicker() {
|
|
202
|
-
const { editor, tf } = useEditorPlugin(TablePlugin);
|
|
203
|
-
|
|
204
|
-
const [tablePicker, setTablePicker] = useState({
|
|
205
|
-
grid: Array.from({ length: 8 }, () => Array.from({ length: 8 }).fill(0)),
|
|
206
|
-
size: { colCount: 0, rowCount: 0 }
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
const onCellMove = (rowIndex: number, colIndex: number) => {
|
|
210
|
-
const newGrid = [...tablePicker.grid];
|
|
211
|
-
|
|
212
|
-
for (let i = 0; i < newGrid.length; i++) {
|
|
213
|
-
for (let j = 0; j < newGrid[i].length; j++) {
|
|
214
|
-
newGrid[i][j]
|
|
215
|
-
= i >= 0 && i <= rowIndex && j >= 0 && j <= colIndex ? 1 : 0;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
setTablePicker({
|
|
220
|
-
grid: newGrid,
|
|
221
|
-
size: { colCount: colIndex + 1, rowCount: rowIndex + 1 }
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
return (
|
|
226
|
-
<div
|
|
227
|
-
className="flex! m-0 flex-col p-0"
|
|
228
|
-
onClick={() => {
|
|
229
|
-
tf.insert.table(tablePicker.size, { select: true });
|
|
230
|
-
editor.tf.focus();
|
|
231
|
-
}}
|
|
232
|
-
role="button">
|
|
233
|
-
<div className="grid size-[130px] grid-cols-8 gap-0.5 p-1">
|
|
234
|
-
{tablePicker.grid.map((rows, rowIndex) => rows.map((value, columIndex) => (
|
|
235
|
-
<div
|
|
236
|
-
key={`(${rowIndex},${columIndex})`}
|
|
237
|
-
className={cn(
|
|
238
|
-
'col-span-1 size-3 border border-solid bg-secondary',
|
|
239
|
-
!!value && 'border-current'
|
|
240
|
-
)}
|
|
241
|
-
onMouseMove={() => {
|
|
242
|
-
onCellMove(rowIndex, columIndex);
|
|
243
|
-
}} />
|
|
244
|
-
)))}
|
|
245
|
-
</div>
|
|
246
|
-
|
|
247
|
-
<div className="text-center text-current text-xs">
|
|
248
|
-
{tablePicker.size.rowCount} x {tablePicker.size.colCount}
|
|
249
|
-
</div>
|
|
250
|
-
</div>
|
|
251
|
-
);
|
|
252
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps } from 'react';
|
|
2
|
-
|
|
3
|
-
import { TextareaAutosize as ReactTextareaAutosize } from '@platejs/caption/react';
|
|
4
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
7
|
-
|
|
8
|
-
export const textareaVariants = cva(
|
|
9
|
-
cn(
|
|
10
|
-
'resize-none text-sm disabled:cursor-not-allowed disabled:opacity-50',
|
|
11
|
-
'placeholder:text-muted-foreground/80'
|
|
12
|
-
),
|
|
13
|
-
{
|
|
14
|
-
defaultVariants: {
|
|
15
|
-
variant: 'default'
|
|
16
|
-
},
|
|
17
|
-
variants: {
|
|
18
|
-
variant: {
|
|
19
|
-
ai: 'max-h-[240px] border-transparent bg-transparent py-2 focus:outline-none focus:ring-0',
|
|
20
|
-
default:
|
|
21
|
-
'rounded-md border-[1.5px] border-input bg-muted/80 px-1 pt-1 pb-0.5 read-only:ring-0 focus:border-brand/50 focus:ring-2 focus:ring-brand/30 read-only:focus:border-input',
|
|
22
|
-
equation: 'max-h-[50vh] min-h-[60px] font-mono text-sm',
|
|
23
|
-
equationInline: 'max-h-[50vh] font-mono text-sm'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
export type TextareaAutosizeProps = ComponentProps<
|
|
30
|
-
typeof ReactTextareaAutosize
|
|
31
|
-
>
|
|
32
|
-
& VariantProps<typeof textareaVariants>;
|
|
33
|
-
|
|
34
|
-
export function Textarea({ className, variant, ...props }: TextareaProps) {
|
|
35
|
-
return (
|
|
36
|
-
<textarea
|
|
37
|
-
className={cn(textareaVariants({ variant }), className)}
|
|
38
|
-
{...props} />
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type TextareaProps = ComponentProps<'textarea'>
|
|
43
|
-
& VariantProps<typeof textareaVariants>;
|
|
44
|
-
|
|
45
|
-
export function TextareaAutosize({
|
|
46
|
-
children: _children,
|
|
47
|
-
className,
|
|
48
|
-
variant,
|
|
49
|
-
...props
|
|
50
|
-
}: TextareaAutosizeProps) {
|
|
51
|
-
return (
|
|
52
|
-
<ReactTextareaAutosize
|
|
53
|
-
autoComplete="off"
|
|
54
|
-
className={cn(textareaVariants({ variant }), className)}
|
|
55
|
-
{...props} />
|
|
56
|
-
);
|
|
57
|
-
}
|