-
Notifications
You must be signed in to change notification settings - Fork 947
[wip]feat: add code-drawing node #4811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[wip]feat: add code-drawing node #4811
Conversation
Add support for rendering PlantUML, Graphviz, Flowchart, and Mermaid diagrams in Plate editor. Includes: - Core plugin implementation with base plugin and transforms - React components for rendering and preview - Floating toolbar for diagram editing - Support for multiple view modes (code/preview) - Utilities for rendering different diagram types
- Add CodeDrawingKit to editor plugin configuration - Create custom CodeDrawingElement component with UI controls - Add code-drawing option to insert toolbar, slash menu, and block context menu - Add example code-drawing content to playground - Improve rendering performance with debounced updates in useCodeDrawingElement hook
…tion - Register code-drawing-node in registry-ui with static component - Add code-drawing-node-static.tsx for SSR support - Fix insertCodeDrawing transform to align with Plate insertion patterns - Add hcodedrawing JSX tag support in test-utils - Add code-drawing documentation and demo examples - Update registry configurations and build outputs
…ayout - Split CodeDrawingPreview into CodeDrawingTextarea, CodeDrawingPreviewArea, CodeDrawingToolbar - Mobile: preview on top, textarea on bottom - Add border separator in Both mode - Fix select background to bg-muted/50 - Toolbar: always visible on mobile, hover on desktop
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: dc3c963 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zbeyens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome PR! Left a few comments.
| @@ -0,0 +1,11 @@ | |||
| 'use client'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base-kits can't use client and React import. See another one for reference.
| title: Code Drawing Node | ||
| --- | ||
|
|
||
| <ComponentPreview name="code-drawing-demo" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this doc is missing from the sidebar
| renderPopover?: (props: { | ||
| children: React.ReactNode; | ||
| onRemove: () => void; | ||
| onDownload?: () => void; | ||
| open: boolean; | ||
| }) => React.ReactNode; | ||
| renderDrawingTypeSelect?: (props: { | ||
| value: CodeDrawingType; | ||
| onChange: (value: CodeDrawingType) => void; | ||
| }) => React.ReactNode; | ||
| renderDrawingModeSelect?: (props: { | ||
| value: ViewMode; | ||
| onChange: (value: ViewMode) => void; | ||
| onOpenChange?: (open: boolean) => void; | ||
| }) => React.ReactNode; | ||
| renderTextarea?: (props: { | ||
| value: string; | ||
| onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void; | ||
| }) => React.ReactNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an anti-pattern. We should have components defined directly in the registry without such props.
| }) => React.ReactNode; | ||
| } | ||
|
|
||
| export function CodeDrawingFloatingToolbar({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, to registry
| }) => React.ReactNode; | ||
| } | ||
|
|
||
| export function CodeDrawingPreview({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, to registry
| toolbar?: React.ReactNode; | ||
| } | ||
|
|
||
| export function CodeDrawingPreviewArea({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, to registry
| toolbar?: React.ReactNode; | ||
| } | ||
|
|
||
| export function CodeDrawingTextarea({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, to registry
| }) => React.ReactNode; | ||
| } | ||
|
|
||
| export function CodeDrawingToolbar({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, to registry
| import * as React from 'react'; | ||
|
|
||
| import { | ||
| CodeDrawingElement as BaseCodeDrawingElement, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To move to this component
|
Nice working! |
Checklist
yarn typecheckyarn lint:fixyarn testyarn brlyarn changesetDesign
Refer to the text drawing nodes in Feishu documents, but they include more library renderings than those.such as
PlantUML,Graphviz, andFlowchartCore Features
Both: Display both code editor and preview simultaneouslyCode: Display only the code editorImage: Display only the rendered diagram resultdrawingType,drawingMode, andcodeuniformly inelement.datafor consistent data managementui
data example
Reference
The design is primarily inspired by Feishu (Lark) Document's text drawing component:
Technical Implementation
lodash/debouncefor debounced renderingcode-block'spre+codewrapper structure to maintain visual consistency with code editors