@fuma-content/studio 0.1.0
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/bin.d.mts +1 -0
- package/dist/bin.mjs +90 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +66 -0
- package/dist/mdx/actions.mjs +34 -0
- package/dist/mdx/client.mjs +167 -0
- package/dist/package.mjs +6 -0
- package/dist/src/components/code-editor/mdx.lazy.mjs +19 -0
- package/dist/src/components/code-editor/mdx.mjs +44 -0
- package/dist/src/components/code-editor/yaml.lazy.mjs +22 -0
- package/dist/src/components/code-editor/yaml.mjs +63 -0
- package/dist/src/components/editor/editor-base-kit.mjs +41 -0
- package/dist/src/components/editor/editor-kit.mjs +73 -0
- package/dist/src/components/editor/md.mjs +42 -0
- package/dist/src/components/editor/plugins/ai-kit.mjs +68 -0
- package/dist/src/components/editor/plugins/align-base-kit.mjs +28 -0
- package/dist/src/components/editor/plugins/align-kit.mjs +30 -0
- package/dist/src/components/editor/plugins/autoformat-kit.mjs +214 -0
- package/dist/src/components/editor/plugins/basic-blocks-base-kit.mjs +22 -0
- package/dist/src/components/editor/plugins/basic-blocks-kit.mjs +51 -0
- package/dist/src/components/editor/plugins/basic-marks-base-kit.mjs +20 -0
- package/dist/src/components/editor/plugins/basic-marks-kit.mjs +28 -0
- package/dist/src/components/editor/plugins/block-menu-kit.mjs +11 -0
- package/dist/src/components/editor/plugins/block-placeholder-kit.mjs +14 -0
- package/dist/src/components/editor/plugins/block-selection-kit.mjs +48 -0
- package/dist/src/components/editor/plugins/callout-base-kit.mjs +8 -0
- package/dist/src/components/editor/plugins/callout-kit.mjs +10 -0
- package/dist/src/components/editor/plugins/code-block-base-kit.mjs +16 -0
- package/dist/src/components/editor/plugins/code-block-kit.mjs +19 -0
- package/dist/src/components/editor/plugins/column-base-kit.mjs +8 -0
- package/dist/src/components/editor/plugins/column-kit.mjs +10 -0
- package/dist/src/components/editor/plugins/comment-base-kit.mjs +8 -0
- package/dist/src/components/editor/plugins/comment-kit.mjs +53 -0
- package/dist/src/components/editor/plugins/copilot-kit.mjs +49 -0
- package/dist/src/components/editor/plugins/cursor-overlay-kit.mjs +11 -0
- package/dist/src/components/editor/plugins/date-base-kit.mjs +8 -0
- package/dist/src/components/editor/plugins/date-kit.mjs +10 -0
- package/dist/src/components/editor/plugins/discussion-kit.mjs +94 -0
- package/dist/src/components/editor/plugins/dnd-kit.mjs +31 -0
- package/dist/src/components/editor/plugins/emoji-kit.mjs +11 -0
- package/dist/src/components/editor/plugins/exit-break-kit.mjs +12 -0
- package/dist/src/components/editor/plugins/fixed-toolbar-kit.mjs +15 -0
- package/dist/src/components/editor/plugins/floating-toolbar-kit.mjs +15 -0
- package/dist/src/components/editor/plugins/font-base-kit.mjs +14 -0
- package/dist/src/components/editor/plugins/font-kit.mjs +19 -0
- package/dist/src/components/editor/plugins/indent-base-kit.mjs +17 -0
- package/dist/src/components/editor/plugins/indent-kit.mjs +20 -0
- package/dist/src/components/editor/plugins/line-height-base-kit.mjs +20 -0
- package/dist/src/components/editor/plugins/line-height-kit.mjs +22 -0
- package/dist/src/components/editor/plugins/link-base-kit.mjs +8 -0
- package/dist/src/components/editor/plugins/link-kit.mjs +15 -0
- package/dist/src/components/editor/plugins/list-base-kit.mjs +19 -0
- package/dist/src/components/editor/plugins/list-kit.mjs +22 -0
- package/dist/src/components/editor/plugins/markdown-kit.mjs +17 -0
- package/dist/src/components/editor/plugins/math-base-kit.mjs +8 -0
- package/dist/src/components/editor/plugins/math-kit.mjs +10 -0
- package/dist/src/components/editor/plugins/media-base-kit.mjs +23 -0
- package/dist/src/components/editor/plugins/media-kit.mjs +37 -0
- package/dist/src/components/editor/plugins/slash-kit.mjs +11 -0
- package/dist/src/components/editor/plugins/suggestion-base-kit.mjs +8 -0
- package/dist/src/components/editor/plugins/suggestion-kit.mjs +50 -0
- package/dist/src/components/editor/plugins/table-base-kit.mjs +13 -0
- package/dist/src/components/editor/plugins/table-kit.mjs +15 -0
- package/dist/src/components/editor/transforms.mjs +125 -0
- package/dist/src/components/editor/ui/ai-chat-editor.mjs +21 -0
- package/dist/src/components/editor/ui/ai-menu.mjs +488 -0
- package/dist/src/components/editor/ui/ai-node.mjs +24 -0
- package/dist/src/components/editor/ui/ai-toolbar-button.mjs +23 -0
- package/dist/src/components/editor/ui/align-toolbar-button.mjs +71 -0
- package/dist/src/components/editor/ui/block-context-menu.mjs +130 -0
- package/dist/src/components/editor/ui/block-discussion.mjs +200 -0
- package/dist/src/components/editor/ui/block-draggable.mjs +265 -0
- package/dist/src/components/editor/ui/block-list-static.mjs +48 -0
- package/dist/src/components/editor/ui/block-list.mjs +47 -0
- package/dist/src/components/editor/ui/block-selection.mjs +28 -0
- package/dist/src/components/editor/ui/block-suggestion.mjs +319 -0
- package/dist/src/components/editor/ui/blockquote-node-static.mjs +14 -0
- package/dist/src/components/editor/ui/blockquote-node.mjs +16 -0
- package/dist/src/components/editor/ui/callout-node-static.mjs +29 -0
- package/dist/src/components/editor/ui/callout-node.mjs +50 -0
- package/dist/src/components/editor/ui/caption.mjs +39 -0
- package/dist/src/components/editor/ui/code-block-node-static.mjs +30 -0
- package/dist/src/components/editor/ui/code-block-node.mjs +121 -0
- package/dist/src/components/editor/ui/code-node-static.mjs +15 -0
- package/dist/src/components/editor/ui/code-node.mjs +17 -0
- package/dist/src/components/editor/ui/column-node-static.mjs +32 -0
- package/dist/src/components/editor/ui/column-node.mjs +229 -0
- package/dist/src/components/editor/ui/comment-node-static.mjs +14 -0
- package/dist/src/components/editor/ui/comment-node.mjs +33 -0
- package/dist/src/components/editor/ui/comment-toolbar-button.mjs +23 -0
- package/dist/src/components/editor/ui/comment.mjs +422 -0
- package/dist/src/components/editor/ui/cursor-overlay.mjs +36 -0
- package/dist/src/components/editor/ui/date-node-static.mjs +32 -0
- package/dist/src/components/editor/ui/date-node.mjs +60 -0
- package/dist/src/components/editor/ui/editor-static.mjs +31 -0
- package/dist/src/components/editor/ui/editor.mjs +60 -0
- package/dist/src/components/editor/ui/emoji-node.mjs +46 -0
- package/dist/src/components/editor/ui/emoji-toolbar-button.mjs +415 -0
- package/dist/src/components/editor/ui/equation-node-static.mjs +65 -0
- package/dist/src/components/editor/ui/equation-node.mjs +159 -0
- package/dist/src/components/editor/ui/equation-toolbar-button.mjs +23 -0
- package/dist/src/components/editor/ui/fixed-toolbar-buttons.mjs +109 -0
- package/dist/src/components/editor/ui/fixed-toolbar.mjs +16 -0
- package/dist/src/components/editor/ui/floating-toolbar-buttons.mjs +54 -0
- package/dist/src/components/editor/ui/floating-toolbar.mjs +51 -0
- package/dist/src/components/editor/ui/font-color-toolbar-button.mjs +637 -0
- package/dist/src/components/editor/ui/font-size-toolbar-button.mjs +83 -0
- package/dist/src/components/editor/ui/ghost-text.mjs +22 -0
- package/dist/src/components/editor/ui/heading-node-static.mjs +60 -0
- package/dist/src/components/editor/ui/heading-node.mjs +62 -0
- package/dist/src/components/editor/ui/highlight-node-static.mjs +15 -0
- package/dist/src/components/editor/ui/highlight-node.mjs +17 -0
- package/dist/src/components/editor/ui/history-toolbar-button.mjs +35 -0
- package/dist/src/components/editor/ui/hr-node-static.mjs +18 -0
- package/dist/src/components/editor/ui/hr-node.mjs +23 -0
- package/dist/src/components/editor/ui/indent-toolbar-button.mjs +29 -0
- package/dist/src/components/editor/ui/inline-combobox.mjs +148 -0
- package/dist/src/components/editor/ui/insert-toolbar-button.mjs +199 -0
- package/dist/src/components/editor/ui/kbd-node-static.mjs +15 -0
- package/dist/src/components/editor/ui/kbd-node.mjs +17 -0
- package/dist/src/components/editor/ui/line-height-toolbar-button.mjs +56 -0
- package/dist/src/components/editor/ui/link-node-static.mjs +20 -0
- package/dist/src/components/editor/ui/link-node.mjs +28 -0
- package/dist/src/components/editor/ui/link-toolbar-button.mjs +21 -0
- package/dist/src/components/editor/ui/link-toolbar.mjs +141 -0
- package/dist/src/components/editor/ui/list-toolbar-button.mjs +131 -0
- package/dist/src/components/editor/ui/mark-toolbar-button.mjs +20 -0
- package/dist/src/components/editor/ui/media-image-node-static.mjs +32 -0
- package/dist/src/components/editor/ui/media-image-node.mjs +64 -0
- package/dist/src/components/editor/ui/media-placeholder-node.mjs +184 -0
- package/dist/src/components/editor/ui/media-preview-dialog.mjs +113 -0
- package/dist/src/components/editor/ui/media-toolbar-button.mjs +156 -0
- package/dist/src/components/editor/ui/media-toolbar.mjs +80 -0
- package/dist/src/components/editor/ui/media-upload-toast.mjs +39 -0
- package/dist/src/components/editor/ui/media-video-node-static.mjs +27 -0
- package/dist/src/components/editor/ui/mode-toolbar-button.mjs +112 -0
- package/dist/src/components/editor/ui/paragraph-node-static.mjs +15 -0
- package/dist/src/components/editor/ui/paragraph-node.mjs +17 -0
- package/dist/src/components/editor/ui/resize-handle.mjs +43 -0
- package/dist/src/components/editor/ui/slash-node.mjs +228 -0
- package/dist/src/components/editor/ui/suggestion-node-static.mjs +24 -0
- package/dist/src/components/editor/ui/suggestion-node.mjs +111 -0
- package/dist/src/components/editor/ui/suggestion-toolbar-button.mjs +24 -0
- package/dist/src/components/editor/ui/table-icons.mjs +1310 -0
- package/dist/src/components/editor/ui/table-node-static.mjs +68 -0
- package/dist/src/components/editor/ui/table-node.mjs +375 -0
- package/dist/src/components/editor/ui/table-toolbar-button.mjs +190 -0
- package/dist/src/components/editor/ui/turn-into-toolbar-button.mjs +168 -0
- package/dist/src/components/editor/use-chat.mjs +80 -0
- package/dist/src/components/json-schema-editor/client.mjs +46 -0
- package/dist/src/components/json-schema-editor/components/inputs.mjs +438 -0
- package/dist/src/components/json-schema-editor/get-default-values.mjs +23 -0
- package/dist/src/components/json-schema-editor/schema.mjs +131 -0
- package/dist/src/components/json-schema-editor/utils/merge-schema.mjs +134 -0
- package/dist/src/components/json-schema-editor/utils/schema-to-string.mjs +53 -0
- package/dist/src/components/ui/alert-dialog.mjs +90 -0
- package/dist/src/components/ui/avatar.mjs +32 -0
- package/dist/src/components/ui/button.mjs +48 -0
- package/dist/src/components/ui/calendar.mjs +108 -0
- package/dist/src/components/ui/checkbox.mjs +23 -0
- package/dist/src/components/ui/combobox.mjs +53 -0
- package/dist/src/components/ui/command.mjs +42 -0
- package/dist/src/components/ui/context-menu.mjs +67 -0
- package/dist/src/components/ui/dialog.mjs +9 -0
- package/dist/src/components/ui/dropdown-menu.mjs +122 -0
- package/dist/src/components/ui/input-group.mjs +31 -0
- package/dist/src/components/ui/input.mjs +15 -0
- package/dist/src/components/ui/label.mjs +19 -0
- package/dist/src/components/ui/popover.mjs +37 -0
- package/dist/src/components/ui/select.mjs +80 -0
- package/dist/src/components/ui/separator.mjs +19 -0
- package/dist/src/components/ui/spinner.mjs +16 -0
- package/dist/src/components/ui/tabs.mjs +39 -0
- package/dist/src/components/ui/textarea.mjs +14 -0
- package/dist/src/components/ui/toolbar.mjs +183 -0
- package/dist/src/components/ui/tooltip.mjs +38 -0
- package/dist/src/hooks/editor/use-is-creator.mjs +19 -0
- package/dist/src/hooks/use-upload-file.mjs +73 -0
- package/dist/src/lib/config.mjs +38 -0
- package/dist/src/lib/data/store.d.mts +15 -0
- package/dist/src/lib/lowlight.mjs +7 -0
- package/dist/src/lib/utils/deep-equal.mjs +18 -0
- package/dist/src/lib/utils/remove-undefined.mjs +18 -0
- package/dist/src/lib/utils.mjs +10 -0
- package/dist/types.d.mts +50 -0
- package/next.config.ts +23 -0
- package/package.json +131 -0
- package/postcss.config.mjs +7 -0
- package/src/app/(dashboard)/collection/[name]/[...slug]/page.client.tsx +26 -0
- package/src/app/(dashboard)/collection/[name]/[...slug]/page.tsx +17 -0
- package/src/app/(dashboard)/collection/[name]/page.client.tsx +82 -0
- package/src/app/(dashboard)/collection/[name]/page.tsx +11 -0
- package/src/app/(dashboard)/layout.tsx +34 -0
- package/src/app/(dashboard)/page.tsx +38 -0
- package/src/app/api/ai/command/prompts.ts +313 -0
- package/src/app/api/ai/command/route.ts +203 -0
- package/src/app/api/ai/command/utils.ts +242 -0
- package/src/app/api/ai/copilot/route.ts +33 -0
- package/src/app/api/uploadthing/route.ts +5 -0
- package/src/app/codeblock/LICENSE +21 -0
- package/src/app/codeblock/styles.css +289 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +223 -0
- package/src/app/layout.client.tsx +15 -0
- package/src/app/layout.tsx +30 -0
- package/src/components/app-sidebar.tsx +162 -0
- package/src/components/code-editor/mdx.lazy.tsx +18 -0
- package/src/components/code-editor/mdx.tsx +48 -0
- package/src/components/code-editor/yaml.lazy.tsx +20 -0
- package/src/components/code-editor/yaml.tsx +71 -0
- package/src/components/collection/actions.tsx +41 -0
- package/src/components/collection/client.tsx +63 -0
- package/src/components/collection/context.tsx +24 -0
- package/src/components/collection/document/actions.tsx +83 -0
- package/src/components/editor/editor-base-kit.tsx +37 -0
- package/src/components/editor/editor-kit.tsx +87 -0
- package/src/components/editor/md.tsx +60 -0
- package/src/components/editor/plugins/ai-kit.tsx +102 -0
- package/src/components/editor/plugins/align-base-kit.tsx +16 -0
- package/src/components/editor/plugins/align-kit.tsx +18 -0
- package/src/components/editor/plugins/autoformat-kit.tsx +236 -0
- package/src/components/editor/plugins/basic-blocks-base-kit.tsx +34 -0
- package/src/components/editor/plugins/basic-blocks-kit.tsx +87 -0
- package/src/components/editor/plugins/basic-marks-base-kit.tsx +26 -0
- package/src/components/editor/plugins/basic-marks-kit.tsx +40 -0
- package/src/components/editor/plugins/basic-nodes-kit.tsx +6 -0
- package/src/components/editor/plugins/block-menu-kit.tsx +14 -0
- package/src/components/editor/plugins/block-placeholder-kit.tsx +17 -0
- package/src/components/editor/plugins/block-selection-kit.tsx +54 -0
- package/src/components/editor/plugins/callout-base-kit.tsx +5 -0
- package/src/components/editor/plugins/callout-kit.tsx +7 -0
- package/src/components/editor/plugins/code-block-base-kit.tsx +16 -0
- package/src/components/editor/plugins/code-block-kit.tsx +19 -0
- package/src/components/editor/plugins/column-base-kit.tsx +11 -0
- package/src/components/editor/plugins/column-kit.tsx +10 -0
- package/src/components/editor/plugins/comment-base-kit.tsx +5 -0
- package/src/components/editor/plugins/comment-kit.tsx +92 -0
- package/src/components/editor/plugins/copilot-kit.tsx +70 -0
- package/src/components/editor/plugins/cursor-overlay-kit.tsx +13 -0
- package/src/components/editor/plugins/date-base-kit.tsx +5 -0
- package/src/components/editor/plugins/date-kit.tsx +7 -0
- package/src/components/editor/plugins/discussion-kit.tsx +142 -0
- package/src/components/editor/plugins/dnd-kit.tsx +25 -0
- package/src/components/editor/plugins/emoji-kit.tsx +13 -0
- package/src/components/editor/plugins/exit-break-kit.tsx +12 -0
- package/src/components/editor/plugins/fixed-toolbar-kit.tsx +19 -0
- package/src/components/editor/plugins/floating-toolbar-kit.tsx +19 -0
- package/src/components/editor/plugins/font-base-kit.tsx +20 -0
- package/src/components/editor/plugins/font-kit.tsx +29 -0
- package/src/components/editor/plugins/indent-base-kit.tsx +13 -0
- package/src/components/editor/plugins/indent-kit.tsx +22 -0
- package/src/components/editor/plugins/line-height-base-kit.tsx +14 -0
- package/src/components/editor/plugins/line-height-kit.tsx +16 -0
- package/src/components/editor/plugins/link-base-kit.tsx +5 -0
- package/src/components/editor/plugins/link-kit.tsx +15 -0
- package/src/components/editor/plugins/list-base-kit.tsx +17 -0
- package/src/components/editor/plugins/list-kit.tsx +26 -0
- package/src/components/editor/plugins/markdown-kit.tsx +13 -0
- package/src/components/editor/plugins/math-base-kit.tsx +11 -0
- package/src/components/editor/plugins/math-kit.tsx +10 -0
- package/src/components/editor/plugins/media-base-kit.tsx +25 -0
- package/src/components/editor/plugins/media-kit.tsx +28 -0
- package/src/components/editor/plugins/slash-kit.tsx +18 -0
- package/src/components/editor/plugins/suggestion-base-kit.tsx +5 -0
- package/src/components/editor/plugins/suggestion-kit.tsx +83 -0
- package/src/components/editor/plugins/table-base-kit.tsx +20 -0
- package/src/components/editor/plugins/table-kit.tsx +22 -0
- package/src/components/editor/settings-dialog.tsx +418 -0
- package/src/components/editor/transforms.ts +193 -0
- package/src/components/editor/types.ts +149 -0
- package/src/components/editor/ui/ai-chat-editor.tsx +20 -0
- package/src/components/editor/ui/ai-menu.tsx +663 -0
- package/src/components/editor/ui/ai-node.tsx +40 -0
- package/src/components/editor/ui/ai-toolbar-button.tsx +23 -0
- package/src/components/editor/ui/align-toolbar-button.tsx +78 -0
- package/src/components/editor/ui/block-context-menu.tsx +154 -0
- package/src/components/editor/ui/block-discussion.tsx +318 -0
- package/src/components/editor/ui/block-draggable.tsx +464 -0
- package/src/components/editor/ui/block-list-static.tsx +75 -0
- package/src/components/editor/ui/block-list.tsx +72 -0
- package/src/components/editor/ui/block-selection.tsx +37 -0
- package/src/components/editor/ui/block-suggestion.tsx +438 -0
- package/src/components/editor/ui/blockquote-node-static.tsx +5 -0
- package/src/components/editor/ui/blockquote-node.tsx +7 -0
- package/src/components/editor/ui/callout-node-static.tsx +30 -0
- package/src/components/editor/ui/callout-node.tsx +64 -0
- package/src/components/editor/ui/caption.tsx +55 -0
- package/src/components/editor/ui/code-block-node-static.tsx +33 -0
- package/src/components/editor/ui/code-block-node.tsx +161 -0
- package/src/components/editor/ui/code-node-static.tsx +15 -0
- package/src/components/editor/ui/code-node.tsx +17 -0
- package/src/components/editor/ui/column-node-static.tsx +27 -0
- package/src/components/editor/ui/column-node.tsx +285 -0
- package/src/components/editor/ui/comment-node-static.tsx +12 -0
- package/src/components/editor/ui/comment-node.tsx +43 -0
- package/src/components/editor/ui/comment-toolbar-button.tsx +24 -0
- package/src/components/editor/ui/comment.tsx +577 -0
- package/src/components/editor/ui/cursor-overlay.tsx +66 -0
- package/src/components/editor/ui/date-node-static.tsx +45 -0
- package/src/components/editor/ui/date-node.tsx +86 -0
- package/src/components/editor/ui/editor-static.tsx +47 -0
- package/src/components/editor/ui/editor.tsx +120 -0
- package/src/components/editor/ui/emoji-node.tsx +65 -0
- package/src/components/editor/ui/emoji-toolbar-button.tsx +582 -0
- package/src/components/editor/ui/equation-node-static.tsx +94 -0
- package/src/components/editor/ui/equation-node.tsx +218 -0
- package/src/components/editor/ui/equation-toolbar-button.tsx +24 -0
- package/src/components/editor/ui/fixed-toolbar-buttons.tsx +135 -0
- package/src/components/editor/ui/fixed-toolbar.tsx +17 -0
- package/src/components/editor/ui/floating-toolbar-buttons.tsx +72 -0
- package/src/components/editor/ui/floating-toolbar.tsx +76 -0
- package/src/components/editor/ui/font-color-toolbar-button.tsx +804 -0
- package/src/components/editor/ui/font-size-toolbar-button.tsx +102 -0
- package/src/components/editor/ui/ghost-text.tsx +27 -0
- package/src/components/editor/ui/heading-node-static.tsx +54 -0
- package/src/components/editor/ui/heading-node.tsx +54 -0
- package/src/components/editor/ui/highlight-node-static.tsx +11 -0
- package/src/components/editor/ui/highlight-node.tsx +13 -0
- package/src/components/editor/ui/history-toolbar-button.tsx +41 -0
- package/src/components/editor/ui/hr-node-static.tsx +16 -0
- package/src/components/editor/ui/hr-node.tsx +28 -0
- package/src/components/editor/ui/indent-toolbar-button.tsx +27 -0
- package/src/components/editor/ui/inline-combobox.tsx +251 -0
- package/src/components/editor/ui/insert-toolbar-button.tsx +242 -0
- package/src/components/editor/ui/kbd-node-static.tsx +15 -0
- package/src/components/editor/ui/kbd-node.tsx +17 -0
- package/src/components/editor/ui/line-height-toolbar-button.tsx +66 -0
- package/src/components/editor/ui/link-node-static.tsx +21 -0
- package/src/components/editor/ui/link-node.tsx +37 -0
- package/src/components/editor/ui/link-toolbar-button.tsx +18 -0
- package/src/components/editor/ui/link-toolbar.tsx +196 -0
- package/src/components/editor/ui/list-toolbar-button.tsx +195 -0
- package/src/components/editor/ui/mark-toolbar-button.tsx +20 -0
- package/src/components/editor/ui/media-image-node-static.tsx +33 -0
- package/src/components/editor/ui/media-image-node.tsx +75 -0
- package/src/components/editor/ui/media-placeholder-node.tsx +235 -0
- package/src/components/editor/ui/media-preview-dialog.tsx +145 -0
- package/src/components/editor/ui/media-toolbar-button.tsx +202 -0
- package/src/components/editor/ui/media-toolbar.tsx +100 -0
- package/src/components/editor/ui/media-upload-toast.tsx +59 -0
- package/src/components/editor/ui/media-video-node-static.tsx +23 -0
- package/src/components/editor/ui/mode-toolbar-button.tsx +121 -0
- package/src/components/editor/ui/paragraph-node-static.tsx +13 -0
- package/src/components/editor/ui/paragraph-node.tsx +15 -0
- package/src/components/editor/ui/resize-handle.tsx +79 -0
- package/src/components/editor/ui/slash-node.tsx +274 -0
- package/src/components/editor/ui/suggestion-node-static.tsx +30 -0
- package/src/components/editor/ui/suggestion-node.tsx +157 -0
- package/src/components/editor/ui/suggestion-toolbar-button.tsx +25 -0
- package/src/components/editor/ui/table-icons.tsx +685 -0
- package/src/components/editor/ui/table-node-static.tsx +86 -0
- package/src/components/editor/ui/table-node.tsx +569 -0
- package/src/components/editor/ui/table-toolbar-button.tsx +260 -0
- package/src/components/editor/ui/turn-into-toolbar-button.tsx +176 -0
- package/src/components/editor/use-chat.ts +120 -0
- package/src/components/icons/logo.tsx +37 -0
- package/src/components/json-schema-editor/client.tsx +55 -0
- package/src/components/json-schema-editor/components/inputs.tsx +612 -0
- package/src/components/json-schema-editor/get-default-values.ts +29 -0
- package/src/components/json-schema-editor/schema.tsx +206 -0
- package/src/components/json-schema-editor/utils/merge-schema.ts +167 -0
- package/src/components/json-schema-editor/utils/schema-to-string.ts +87 -0
- package/src/components/nav-user.tsx +102 -0
- package/src/components/site-header.tsx +13 -0
- package/src/components/ui/alert-dialog.tsx +182 -0
- package/src/components/ui/avatar.tsx +96 -0
- package/src/components/ui/badge.tsx +46 -0
- package/src/components/ui/button.tsx +65 -0
- package/src/components/ui/calendar.tsx +186 -0
- package/src/components/ui/checkbox.tsx +29 -0
- package/src/components/ui/combobox.tsx +267 -0
- package/src/components/ui/command.tsx +180 -0
- package/src/components/ui/context-menu.tsx +161 -0
- package/src/components/ui/dialog.tsx +142 -0
- package/src/components/ui/drawer.tsx +120 -0
- package/src/components/ui/dropdown-menu.tsx +239 -0
- package/src/components/ui/field.tsx +224 -0
- package/src/components/ui/input-group.tsx +144 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/label.tsx +18 -0
- package/src/components/ui/popover.tsx +76 -0
- package/src/components/ui/select.tsx +182 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/sheet.tsx +130 -0
- package/src/components/ui/sidebar.tsx +608 -0
- package/src/components/ui/sonner.tsx +45 -0
- package/src/components/ui/spinner.tsx +15 -0
- package/src/components/ui/table.tsx +89 -0
- package/src/components/ui/tabs.tsx +60 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/toggle-group.tsx +86 -0
- package/src/components/ui/toggle.tsx +45 -0
- package/src/components/ui/toolbar.tsx +365 -0
- package/src/components/ui/tooltip.tsx +57 -0
- package/src/hooks/editor/use-is-creator.ts +21 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-mounted.ts +11 -0
- package/src/hooks/use-upload-file.ts +121 -0
- package/src/lib/ai/markdown-joiner-transform.ts +235 -0
- package/src/lib/config.ts +60 -0
- package/src/lib/data/actions.ts +51 -0
- package/src/lib/data/boundary.client.tsx +22 -0
- package/src/lib/data/boundary.tsx +22 -0
- package/src/lib/data/query.ts +9 -0
- package/src/lib/data/store.ts +52 -0
- package/src/lib/lowlight.ts +3 -0
- package/src/lib/uploadthing.ts +19 -0
- package/src/lib/utils/deep-equal.ts +37 -0
- package/src/lib/utils/remove-undefined.ts +21 -0
- package/src/lib/utils/urls.ts +6 -0
- package/src/lib/utils.ts +6 -0
- package/tsconfig.build.json +24 -0
- package/tsconfig.json +37 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { TResolvedSuggestion } from "@platejs/suggestion";
|
|
4
|
+
import {
|
|
5
|
+
acceptSuggestion,
|
|
6
|
+
getSuggestionKey,
|
|
7
|
+
keyId2SuggestionId,
|
|
8
|
+
rejectSuggestion,
|
|
9
|
+
} from "@platejs/suggestion";
|
|
10
|
+
import { SuggestionPlugin } from "@platejs/suggestion/react";
|
|
11
|
+
import { CheckIcon, XIcon } from "lucide-react";
|
|
12
|
+
import {
|
|
13
|
+
ElementApi,
|
|
14
|
+
KEYS,
|
|
15
|
+
type NodeEntry,
|
|
16
|
+
type Path,
|
|
17
|
+
PathApi,
|
|
18
|
+
type TElement,
|
|
19
|
+
TextApi,
|
|
20
|
+
type TSuggestionText,
|
|
21
|
+
} from "platejs";
|
|
22
|
+
import { useEditorPlugin, usePluginOption } from "platejs/react";
|
|
23
|
+
import * as React from "react";
|
|
24
|
+
import { discussionPlugin, type TDiscussion } from "@/components/editor/plugins/discussion-kit";
|
|
25
|
+
import { suggestionPlugin } from "@/components/editor/plugins/suggestion-kit";
|
|
26
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
|
27
|
+
import { Button } from "@/components/ui/button";
|
|
28
|
+
|
|
29
|
+
import { Comment, CommentCreateForm, formatCommentDate, type TComment } from "./comment";
|
|
30
|
+
|
|
31
|
+
export interface ResolvedSuggestion extends TResolvedSuggestion {
|
|
32
|
+
comments: TComment[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const BLOCK_SUGGESTION = "__block__";
|
|
36
|
+
|
|
37
|
+
const TYPE_TEXT_MAP: Record<string, (node?: TElement) => string> = {
|
|
38
|
+
[KEYS.audio]: () => "Audio",
|
|
39
|
+
[KEYS.blockquote]: () => "Blockquote",
|
|
40
|
+
[KEYS.callout]: () => "Callout",
|
|
41
|
+
[KEYS.codeBlock]: () => "Code Block",
|
|
42
|
+
[KEYS.column]: () => "Column",
|
|
43
|
+
[KEYS.equation]: () => "Equation",
|
|
44
|
+
[KEYS.file]: () => "File",
|
|
45
|
+
[KEYS.h1]: () => "Heading 1",
|
|
46
|
+
[KEYS.h2]: () => "Heading 2",
|
|
47
|
+
[KEYS.h3]: () => "Heading 3",
|
|
48
|
+
[KEYS.h4]: () => "Heading 4",
|
|
49
|
+
[KEYS.h5]: () => "Heading 5",
|
|
50
|
+
[KEYS.h6]: () => "Heading 6",
|
|
51
|
+
[KEYS.hr]: () => "Horizontal Rule",
|
|
52
|
+
[KEYS.img]: () => "Image",
|
|
53
|
+
[KEYS.mediaEmbed]: () => "Media",
|
|
54
|
+
[KEYS.p]: (node) => {
|
|
55
|
+
if (node?.[KEYS.listType] === KEYS.listTodo) return "Todo List";
|
|
56
|
+
if (node?.[KEYS.listType] === KEYS.ol) return "Ordered List";
|
|
57
|
+
if (node?.[KEYS.listType] === KEYS.ul) return "List";
|
|
58
|
+
|
|
59
|
+
return "Paragraph";
|
|
60
|
+
},
|
|
61
|
+
[KEYS.table]: () => "Table",
|
|
62
|
+
[KEYS.toc]: () => "Table of Contents",
|
|
63
|
+
[KEYS.toggle]: () => "Toggle",
|
|
64
|
+
[KEYS.video]: () => "Video",
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export function BlockSuggestionCard({
|
|
68
|
+
idx,
|
|
69
|
+
isLast,
|
|
70
|
+
suggestion,
|
|
71
|
+
}: {
|
|
72
|
+
idx: number;
|
|
73
|
+
isLast: boolean;
|
|
74
|
+
suggestion: ResolvedSuggestion;
|
|
75
|
+
}) {
|
|
76
|
+
const { api, editor } = useEditorPlugin(SuggestionPlugin);
|
|
77
|
+
|
|
78
|
+
const userInfo = usePluginOption(discussionPlugin, "user", suggestion.userId);
|
|
79
|
+
|
|
80
|
+
const accept = (suggestion: ResolvedSuggestion) => {
|
|
81
|
+
api.suggestion.withoutSuggestions(() => {
|
|
82
|
+
acceptSuggestion(editor, suggestion);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const reject = (suggestion: ResolvedSuggestion) => {
|
|
87
|
+
api.suggestion.withoutSuggestions(() => {
|
|
88
|
+
rejectSuggestion(editor, suggestion);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const [hovering, setHovering] = React.useState(false);
|
|
93
|
+
|
|
94
|
+
const suggestionText2Array = (text: string) => {
|
|
95
|
+
if (text === BLOCK_SUGGESTION) return ["line breaks"];
|
|
96
|
+
|
|
97
|
+
return text.split(BLOCK_SUGGESTION).filter(Boolean);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const [editingId, setEditingId] = React.useState<string | null>(null);
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div
|
|
104
|
+
key={`${suggestion.suggestionId}-${idx}`}
|
|
105
|
+
className="relative"
|
|
106
|
+
onMouseEnter={() => setHovering(true)}
|
|
107
|
+
onMouseLeave={() => setHovering(false)}
|
|
108
|
+
>
|
|
109
|
+
<div className="flex flex-col p-4">
|
|
110
|
+
<div className="relative flex items-center">
|
|
111
|
+
{/* Replace to your own backend or refer to potion */}
|
|
112
|
+
<Avatar className="size-5">
|
|
113
|
+
<AvatarImage alt={userInfo?.name} src={userInfo?.avatarUrl} />
|
|
114
|
+
<AvatarFallback>{userInfo?.name?.[0]}</AvatarFallback>
|
|
115
|
+
</Avatar>
|
|
116
|
+
<h4 className="mx-2 font-semibold text-sm leading-none">{userInfo?.name}</h4>
|
|
117
|
+
<div className="text-muted-foreground/80 text-xs leading-none">
|
|
118
|
+
<span className="mr-1">{formatCommentDate(new Date(suggestion.createdAt))}</span>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<div className="relative mt-1 mb-4 pl-[32px]">
|
|
123
|
+
<div className="flex flex-col gap-2">
|
|
124
|
+
{suggestion.type === "remove" &&
|
|
125
|
+
suggestionText2Array(suggestion.text!).map((text, index) => (
|
|
126
|
+
<div key={index} className="flex items-center gap-2">
|
|
127
|
+
<span className="text-muted-foreground text-sm">Delete:</span>
|
|
128
|
+
|
|
129
|
+
<span key={index} className="text-sm">
|
|
130
|
+
{text}
|
|
131
|
+
</span>
|
|
132
|
+
</div>
|
|
133
|
+
))}
|
|
134
|
+
|
|
135
|
+
{suggestion.type === "insert" &&
|
|
136
|
+
suggestionText2Array(suggestion.newText!).map((text, index) => (
|
|
137
|
+
<div key={index} className="flex items-center gap-2">
|
|
138
|
+
<span className="text-muted-foreground text-sm">Add:</span>
|
|
139
|
+
|
|
140
|
+
<span key={index} className="text-sm">
|
|
141
|
+
{text || "line breaks"}
|
|
142
|
+
</span>
|
|
143
|
+
</div>
|
|
144
|
+
))}
|
|
145
|
+
|
|
146
|
+
{suggestion.type === "replace" && (
|
|
147
|
+
<div className="flex flex-col gap-2">
|
|
148
|
+
{suggestionText2Array(suggestion.newText!).map((text, index) => (
|
|
149
|
+
<React.Fragment key={index}>
|
|
150
|
+
<div key={index} className="flex items-start gap-2 text-brand/80">
|
|
151
|
+
<span className="text-sm">with:</span>
|
|
152
|
+
<span className="text-sm">{text || "line breaks"}</span>
|
|
153
|
+
</div>
|
|
154
|
+
</React.Fragment>
|
|
155
|
+
))}
|
|
156
|
+
|
|
157
|
+
{suggestionText2Array(suggestion.text!).map((text, index) => (
|
|
158
|
+
<React.Fragment key={index}>
|
|
159
|
+
<div key={index} className="flex items-start gap-2">
|
|
160
|
+
<span className="text-muted-foreground text-sm">
|
|
161
|
+
{index === 0 ? "Replace:" : "Delete:"}
|
|
162
|
+
</span>
|
|
163
|
+
<span className="text-sm">{text || "line breaks"}</span>
|
|
164
|
+
</div>
|
|
165
|
+
</React.Fragment>
|
|
166
|
+
))}
|
|
167
|
+
</div>
|
|
168
|
+
)}
|
|
169
|
+
|
|
170
|
+
{suggestion.type === "update" && (
|
|
171
|
+
<div className="flex items-center gap-2">
|
|
172
|
+
<span className="text-muted-foreground text-sm">
|
|
173
|
+
{Object.keys(suggestion.properties).map((key) => (
|
|
174
|
+
<span key={key}>Un{key}</span>
|
|
175
|
+
))}
|
|
176
|
+
|
|
177
|
+
{Object.keys(suggestion.newProperties).map((key) => (
|
|
178
|
+
<span key={key}>{key.charAt(0).toUpperCase() + key.slice(1)}</span>
|
|
179
|
+
))}
|
|
180
|
+
</span>
|
|
181
|
+
<span className="text-sm">{suggestion.newText}</span>
|
|
182
|
+
</div>
|
|
183
|
+
)}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
{suggestion.comments.map((comment, index) => (
|
|
188
|
+
<Comment
|
|
189
|
+
key={comment.id ?? index}
|
|
190
|
+
comment={comment}
|
|
191
|
+
discussionLength={suggestion.comments.length}
|
|
192
|
+
documentContent="__suggestion__"
|
|
193
|
+
editingId={editingId}
|
|
194
|
+
index={index}
|
|
195
|
+
setEditingId={setEditingId}
|
|
196
|
+
/>
|
|
197
|
+
))}
|
|
198
|
+
|
|
199
|
+
{hovering && (
|
|
200
|
+
<div className="absolute top-4 right-4 flex gap-2">
|
|
201
|
+
<Button
|
|
202
|
+
variant="ghost"
|
|
203
|
+
className="size-6 p-1 text-muted-foreground"
|
|
204
|
+
onClick={() => accept(suggestion)}
|
|
205
|
+
>
|
|
206
|
+
<CheckIcon className="size-4" />
|
|
207
|
+
</Button>
|
|
208
|
+
|
|
209
|
+
<Button
|
|
210
|
+
variant="ghost"
|
|
211
|
+
className="size-6 p-1 text-muted-foreground"
|
|
212
|
+
onClick={() => reject(suggestion)}
|
|
213
|
+
>
|
|
214
|
+
<XIcon className="size-4" />
|
|
215
|
+
</Button>
|
|
216
|
+
</div>
|
|
217
|
+
)}
|
|
218
|
+
|
|
219
|
+
<CommentCreateForm discussionId={suggestion.suggestionId} />
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
{!isLast && <div className="h-px w-full bg-muted" />}
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export const useResolveSuggestion = (
|
|
228
|
+
suggestionNodes: NodeEntry<TElement | TSuggestionText>[],
|
|
229
|
+
blockPath: Path,
|
|
230
|
+
) => {
|
|
231
|
+
const discussions = usePluginOption(discussionPlugin, "discussions");
|
|
232
|
+
|
|
233
|
+
const { api, editor, getOption, setOption } = useEditorPlugin(suggestionPlugin);
|
|
234
|
+
|
|
235
|
+
suggestionNodes.forEach(([node]) => {
|
|
236
|
+
const id = api.suggestion.nodeId(node);
|
|
237
|
+
const map = getOption("uniquePathMap");
|
|
238
|
+
|
|
239
|
+
if (!id) return;
|
|
240
|
+
|
|
241
|
+
const previousPath = map.get(id);
|
|
242
|
+
|
|
243
|
+
// If there are no suggestion nodes in the corresponding path in the map, then update it.
|
|
244
|
+
if (PathApi.isPath(previousPath)) {
|
|
245
|
+
const nodes = api.suggestion.node({ id, at: previousPath, isText: true });
|
|
246
|
+
const parentNode = api.node(previousPath);
|
|
247
|
+
let lineBreakId: string | null = null;
|
|
248
|
+
|
|
249
|
+
if (parentNode && ElementApi.isElement(parentNode[0])) {
|
|
250
|
+
lineBreakId = api.suggestion.nodeId(parentNode[0]) ?? null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!nodes && lineBreakId !== id) {
|
|
254
|
+
setOption("uniquePathMap", new Map(map).set(id, blockPath));
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
setOption("uniquePathMap", new Map(map).set(id, blockPath));
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const resolvedSuggestion: ResolvedSuggestion[] = React.useMemo(() => {
|
|
262
|
+
const map = getOption("uniquePathMap");
|
|
263
|
+
|
|
264
|
+
if (suggestionNodes.length === 0) return [];
|
|
265
|
+
|
|
266
|
+
const suggestionIds = new Set(
|
|
267
|
+
suggestionNodes
|
|
268
|
+
.flatMap(([node]) => {
|
|
269
|
+
if (TextApi.isText(node)) {
|
|
270
|
+
const dataList = api.suggestion.dataList(node);
|
|
271
|
+
const includeUpdate = dataList.some((data) => data.type === "update");
|
|
272
|
+
|
|
273
|
+
if (!includeUpdate) {
|
|
274
|
+
return api.suggestion.nodeId(node) ?? [];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return dataList.filter((data) => data.type === "update").map((d) => d.id);
|
|
278
|
+
}
|
|
279
|
+
if (ElementApi.isElement(node)) {
|
|
280
|
+
return api.suggestion.nodeId(node) ?? [];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return [];
|
|
284
|
+
})
|
|
285
|
+
.filter(Boolean),
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
const res: ResolvedSuggestion[] = [];
|
|
289
|
+
|
|
290
|
+
suggestionIds.forEach((id) => {
|
|
291
|
+
if (!id) return;
|
|
292
|
+
|
|
293
|
+
const path = map.get(id);
|
|
294
|
+
|
|
295
|
+
if (!path || !PathApi.isPath(path)) return;
|
|
296
|
+
if (!PathApi.equals(path, blockPath)) return;
|
|
297
|
+
|
|
298
|
+
const entries = [
|
|
299
|
+
...editor.api.nodes<TElement | TSuggestionText>({
|
|
300
|
+
at: [],
|
|
301
|
+
mode: "all",
|
|
302
|
+
match: (n) =>
|
|
303
|
+
(n[KEYS.suggestion] && n[getSuggestionKey(id)]) ||
|
|
304
|
+
api.suggestion.nodeId(n as TElement) === id,
|
|
305
|
+
}),
|
|
306
|
+
];
|
|
307
|
+
|
|
308
|
+
// move line break to the end
|
|
309
|
+
entries.sort(([, path1], [, path2]) => (PathApi.isChild(path1, path2) ? -1 : 1));
|
|
310
|
+
|
|
311
|
+
let newText = "";
|
|
312
|
+
let text = "";
|
|
313
|
+
let properties: any = {};
|
|
314
|
+
let newProperties: any = {};
|
|
315
|
+
|
|
316
|
+
// overlapping suggestion
|
|
317
|
+
entries.forEach(([node]) => {
|
|
318
|
+
if (TextApi.isText(node)) {
|
|
319
|
+
const dataList = api.suggestion.dataList(node);
|
|
320
|
+
|
|
321
|
+
dataList.forEach((data) => {
|
|
322
|
+
if (data.id === id) {
|
|
323
|
+
switch (data.type) {
|
|
324
|
+
case "insert": {
|
|
325
|
+
newText += node.text;
|
|
326
|
+
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
case "remove": {
|
|
330
|
+
text += node.text;
|
|
331
|
+
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case "update": {
|
|
335
|
+
properties = {
|
|
336
|
+
...properties,
|
|
337
|
+
...data.properties,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
newProperties = {
|
|
341
|
+
...newProperties,
|
|
342
|
+
...data.newProperties,
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
newText += node.text;
|
|
346
|
+
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
// No default
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
const lineBreakData = api.suggestion.isBlockSuggestion(node)
|
|
355
|
+
? node.suggestion
|
|
356
|
+
: undefined;
|
|
357
|
+
|
|
358
|
+
if (lineBreakData?.id === keyId2SuggestionId(id)) {
|
|
359
|
+
if (lineBreakData.type === "insert") {
|
|
360
|
+
newText += lineBreakData.isLineBreak
|
|
361
|
+
? BLOCK_SUGGESTION
|
|
362
|
+
: BLOCK_SUGGESTION + TYPE_TEXT_MAP[node.type](node);
|
|
363
|
+
} else if (lineBreakData.type === "remove") {
|
|
364
|
+
text += lineBreakData.isLineBreak
|
|
365
|
+
? BLOCK_SUGGESTION
|
|
366
|
+
: BLOCK_SUGGESTION + TYPE_TEXT_MAP[node.type](node);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
if (entries.length === 0) return;
|
|
373
|
+
|
|
374
|
+
const nodeData = api.suggestion.suggestionData(entries[0][0]);
|
|
375
|
+
|
|
376
|
+
if (!nodeData) return;
|
|
377
|
+
|
|
378
|
+
// const comments = data?.discussions.find((d) => d.id === id)?.comments;
|
|
379
|
+
const comments = discussions.find((s: TDiscussion) => s.id === id)?.comments || [];
|
|
380
|
+
const createdAt = new Date(nodeData.createdAt);
|
|
381
|
+
|
|
382
|
+
const keyId = getSuggestionKey(id);
|
|
383
|
+
|
|
384
|
+
if (nodeData.type === "update") {
|
|
385
|
+
res.push({
|
|
386
|
+
comments,
|
|
387
|
+
createdAt,
|
|
388
|
+
keyId,
|
|
389
|
+
newProperties,
|
|
390
|
+
newText,
|
|
391
|
+
properties,
|
|
392
|
+
suggestionId: keyId2SuggestionId(id),
|
|
393
|
+
type: "update",
|
|
394
|
+
userId: nodeData.userId,
|
|
395
|
+
});
|
|
396
|
+
} else if (newText.length > 0 && text.length > 0) {
|
|
397
|
+
res.push({
|
|
398
|
+
comments,
|
|
399
|
+
createdAt,
|
|
400
|
+
keyId,
|
|
401
|
+
newText,
|
|
402
|
+
suggestionId: keyId2SuggestionId(id),
|
|
403
|
+
text,
|
|
404
|
+
type: "replace",
|
|
405
|
+
userId: nodeData.userId,
|
|
406
|
+
});
|
|
407
|
+
} else if (newText.length > 0) {
|
|
408
|
+
res.push({
|
|
409
|
+
comments,
|
|
410
|
+
createdAt,
|
|
411
|
+
keyId,
|
|
412
|
+
newText,
|
|
413
|
+
suggestionId: keyId2SuggestionId(id),
|
|
414
|
+
type: "insert",
|
|
415
|
+
userId: nodeData.userId,
|
|
416
|
+
});
|
|
417
|
+
} else if (text.length > 0) {
|
|
418
|
+
res.push({
|
|
419
|
+
comments,
|
|
420
|
+
createdAt,
|
|
421
|
+
keyId,
|
|
422
|
+
suggestionId: keyId2SuggestionId(id),
|
|
423
|
+
text,
|
|
424
|
+
type: "remove",
|
|
425
|
+
userId: nodeData.userId,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
return res;
|
|
431
|
+
}, [api.suggestion, blockPath, discussions, editor.api, getOption, suggestionNodes]);
|
|
432
|
+
|
|
433
|
+
return resolvedSuggestion;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
export const isResolvedSuggestion = (
|
|
437
|
+
suggestion: ResolvedSuggestion | TDiscussion,
|
|
438
|
+
): suggestion is ResolvedSuggestion => "suggestionId" in suggestion;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SlateElementProps } from "platejs/static";
|
|
2
|
+
|
|
3
|
+
import { SlateElement } from "platejs/static";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
export function CalloutElementStatic({ children, className, ...props }: SlateElementProps) {
|
|
8
|
+
return (
|
|
9
|
+
<SlateElement
|
|
10
|
+
className={cn("my-1 flex rounded-sm bg-muted p-4 pl-3", className)}
|
|
11
|
+
style={{
|
|
12
|
+
backgroundColor: props.element.backgroundColor as any,
|
|
13
|
+
}}
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
<div className="flex w-full gap-2 rounded-md">
|
|
17
|
+
<div
|
|
18
|
+
className="size-6 select-none text-[18px]"
|
|
19
|
+
style={{
|
|
20
|
+
fontFamily:
|
|
21
|
+
'"Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", EmojiSymbols',
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
<span data-plate-prevent-deserialization>{(props.element.icon as any) || "💡"}</span>
|
|
25
|
+
</div>
|
|
26
|
+
<div className="w-full">{children}</div>
|
|
27
|
+
</div>
|
|
28
|
+
</SlateElement>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { useCalloutEmojiPicker } from "@platejs/callout/react";
|
|
6
|
+
import { useEmojiDropdownMenuState } from "@platejs/emoji/react";
|
|
7
|
+
import { PlateElement } from "platejs/react";
|
|
8
|
+
|
|
9
|
+
import { Button } from "@/components/ui/button";
|
|
10
|
+
import { cn } from "@/lib/utils";
|
|
11
|
+
|
|
12
|
+
import { EmojiPicker, EmojiPopover } from "./emoji-toolbar-button";
|
|
13
|
+
|
|
14
|
+
export function CalloutElement({
|
|
15
|
+
attributes,
|
|
16
|
+
children,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: React.ComponentProps<typeof PlateElement>) {
|
|
20
|
+
const { emojiPickerState, isOpen, setIsOpen } = useEmojiDropdownMenuState({
|
|
21
|
+
closeOnSelect: true,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const { emojiToolbarDropdownProps, props: calloutProps } = useCalloutEmojiPicker({
|
|
25
|
+
isOpen,
|
|
26
|
+
setIsOpen,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<PlateElement
|
|
31
|
+
className={cn("my-1 flex rounded-sm bg-muted p-4 pl-3", className)}
|
|
32
|
+
style={{
|
|
33
|
+
backgroundColor: props.element.backgroundColor as any,
|
|
34
|
+
}}
|
|
35
|
+
attributes={{
|
|
36
|
+
...attributes,
|
|
37
|
+
"data-plate-open-context-menu": true,
|
|
38
|
+
}}
|
|
39
|
+
{...props}
|
|
40
|
+
>
|
|
41
|
+
<div className="flex w-full gap-2 rounded-md">
|
|
42
|
+
<EmojiPopover
|
|
43
|
+
{...emojiToolbarDropdownProps}
|
|
44
|
+
control={
|
|
45
|
+
<Button
|
|
46
|
+
variant="ghost"
|
|
47
|
+
className="size-6 select-none p-1 text-[18px] hover:bg-muted-foreground/15"
|
|
48
|
+
style={{
|
|
49
|
+
fontFamily:
|
|
50
|
+
'"Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", EmojiSymbols',
|
|
51
|
+
}}
|
|
52
|
+
contentEditable={false}
|
|
53
|
+
>
|
|
54
|
+
{(props.element.icon as any) || "💡"}
|
|
55
|
+
</Button>
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
<EmojiPicker {...emojiPickerState} {...calloutProps} />
|
|
59
|
+
</EmojiPopover>
|
|
60
|
+
<div className="w-full">{children}</div>
|
|
61
|
+
</div>
|
|
62
|
+
</PlateElement>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
|
|
5
|
+
import type { VariantProps } from "class-variance-authority";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Caption as CaptionPrimitive,
|
|
9
|
+
CaptionTextarea as CaptionTextareaPrimitive,
|
|
10
|
+
useCaptionButton,
|
|
11
|
+
useCaptionButtonState,
|
|
12
|
+
} from "@platejs/caption/react";
|
|
13
|
+
import { cva } from "class-variance-authority";
|
|
14
|
+
import { Button } from "@/components/ui/button";
|
|
15
|
+
import { cn } from "@/lib/utils";
|
|
16
|
+
|
|
17
|
+
const captionVariants = cva("max-w-full", {
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
align: "center",
|
|
20
|
+
},
|
|
21
|
+
variants: {
|
|
22
|
+
align: {
|
|
23
|
+
center: "mx-auto",
|
|
24
|
+
left: "mr-auto",
|
|
25
|
+
right: "ml-auto",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export function Caption({
|
|
31
|
+
align,
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}: React.ComponentProps<typeof CaptionPrimitive> & VariantProps<typeof captionVariants>) {
|
|
35
|
+
return <CaptionPrimitive {...props} className={cn(captionVariants({ align }), className)} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function CaptionTextarea(props: React.ComponentProps<typeof CaptionTextareaPrimitive>) {
|
|
39
|
+
return (
|
|
40
|
+
<CaptionTextareaPrimitive
|
|
41
|
+
{...props}
|
|
42
|
+
className={cn(
|
|
43
|
+
"mt-2 w-full resize-none border-none bg-inherit p-0 font-[inherit] text-inherit",
|
|
44
|
+
"focus:outline-none focus:placeholder:opacity-0",
|
|
45
|
+
"text-center print:placeholder:text-transparent",
|
|
46
|
+
props.className,
|
|
47
|
+
)}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function CaptionButton(props: React.ComponentProps<typeof Button>) {
|
|
53
|
+
const state = useCaptionButtonState();
|
|
54
|
+
return <Button {...props} {...useCaptionButton(state)} />;
|
|
55
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TCodeBlockElement } from "platejs";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type SlateElementProps,
|
|
5
|
+
type SlateLeafProps,
|
|
6
|
+
SlateElement,
|
|
7
|
+
SlateLeaf,
|
|
8
|
+
} from "platejs/static";
|
|
9
|
+
|
|
10
|
+
export function CodeBlockElementStatic(props: SlateElementProps<TCodeBlockElement>) {
|
|
11
|
+
return (
|
|
12
|
+
<SlateElement
|
|
13
|
+
className="py-1 **:[.hljs-addition]:bg-[#f0fff4] **:[.hljs-addition]:text-[#22863a] dark:**:[.hljs-addition]:bg-[#3c5743] dark:**:[.hljs-addition]:text-[#ceead5] **:[.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable]:text-[#005cc5] dark:**:[.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable]:text-[#6596cf] **:[.hljs-built\\\\_in,.hljs-symbol]:text-[#e36209] dark:**:[.hljs-built\\\\_in,.hljs-symbol]:text-[#c3854e] **:[.hljs-bullet]:text-[#735c0f] **:[.hljs-comment,.hljs-code,.hljs-formula]:text-[#6a737d] dark:**:[.hljs-comment,.hljs-code,.hljs-formula]:text-[#6a737d] **:[.hljs-deletion]:bg-[#ffeef0] **:[.hljs-deletion]:text-[#b31d28] dark:**:[.hljs-deletion]:bg-[#473235] dark:**:[.hljs-deletion]:text-[#e7c7cb] **:[.hljs-emphasis]:italic **:[.hljs-keyword,.hljs-doctag,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language\\\\_]:text-[#d73a49] dark:**:[.hljs-keyword,.hljs-doctag,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language\\\\_]:text-[#ee6960] **:[.hljs-name,.hljs-quote,.hljs-selector-tag,.hljs-selector-pseudo]:text-[#22863a] dark:**:[.hljs-name,.hljs-quote,.hljs-selector-tag,.hljs-selector-pseudo]:text-[#36a84f] **:[.hljs-regexp,.hljs-string,.hljs-meta_.hljs-string]:text-[#032f62] dark:**:[.hljs-regexp,.hljs-string,.hljs-meta_.hljs-string]:text-[#3593ff] **:[.hljs-section]:font-bold **:[.hljs-section]:text-[#005cc5] dark:**:[.hljs-section]:text-[#61a5f2] **:[.hljs-strong]:font-bold **:[.hljs-title,.hljs-title.class\\\\_,.hljs-title.class\\\\_.inherited\\\\_\\\\_,.hljs-title.function\\\\_]:text-[#6f42c1] dark:**:[.hljs-title,.hljs-title.class\\\\_,.hljs-title.class\\\\_.inherited\\\\_\\\\_,.hljs-title.function\\\\_]:text-[#a77bfa]"
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
<div className="relative rounded-md bg-muted/50">
|
|
17
|
+
<pre className="overflow-x-auto p-8 pr-4 font-mono text-sm leading-[normal] [tab-size:2] print:break-inside-avoid">
|
|
18
|
+
<code>{props.children}</code>
|
|
19
|
+
</pre>
|
|
20
|
+
</div>
|
|
21
|
+
</SlateElement>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function CodeLineElementStatic(props: SlateElementProps) {
|
|
26
|
+
return <SlateElement {...props} />;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function CodeSyntaxLeafStatic(props: SlateLeafProps) {
|
|
30
|
+
const tokenClassName = props.leaf.className as string;
|
|
31
|
+
|
|
32
|
+
return <SlateLeaf className={tokenClassName} {...props} />;
|
|
33
|
+
}
|