-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
feat: support custom elements in @excalidraw/excalidraw #5164
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/components/App.tsx
Outdated
if ( | ||
prevState.scrollX !== this.state.scrollX || | ||
prevState.scrollY !== this.state.scrollY | ||
) { | ||
this.props?.onScrollChange?.(this.state.scrollX, this.state.scrollY); | ||
} | ||
if ( | ||
prevState.offsetLeft !== this.state.offsetLeft || | ||
prevState.offsetTop !== this.state.offsetTop | ||
) { | ||
this.props?.onOffsetsChange?.( | ||
this.state.offsetLeft, | ||
this.state.offsetTop, | ||
); | ||
} | ||
|
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.
for the MVP I'd do this in the host app until we're confident on the API
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.
Removed onOffsetsChange
as its not needed since custom element is positioned absolute but onScrollChange
is definitely needed to update the position of the custom elements (as shown in example) when canvas is scrolled so I would want to export an API instead of maintaining the logic in host.
I am glad this is moving forward. For further extensions of #5164, here are some considerations from #2993 besides my earlier comments:
Custom The element properties sidebar forms a standard part of the Excalidraw UI. This would provide a natural way for users to set custom elements' properties ( Charts feature: It could be useful for the titles and/or axis labels of charts to support custom |
custom-elements.mp4
Take 2 for custom elements API
This PR integrates custom elements on top of canvas so host can use any render props to render the widget for custom elements
TODOS
Add api to
setCustomType
Add api
onCustomElementPointerDown
which will help host to render custom elementAdd api
onScrollChange
which host can use to update custom element positions when scrollingAdd example to showcase custom element integration (see above video / check the preview
When offsets updated there is a delay in elements being updated in host
The custom elements shouldn't overflow the container when scrolled
update docs