-
-
Notifications
You must be signed in to change notification settings - Fork 429
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(edgeless): add views and event support for canvas elements #8882
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
|
Your org has enabled the Graphite merge queue for merging into masterAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
How to use the Graphite Merge QueueAdd the label merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 91118b8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
b7b2b40
to
b204cec
Compare
packages/blocks/src/root-block/edgeless/gfx-tool/default-tool-ext/event-ext.ts
Outdated
Show resolved
Hide resolved
08bab64
to
760c08f
Compare
b204cec
to
35b315f
Compare
packages/blocks/src/root-block/edgeless/gfx-tool/default-tool-ext/event-ext.ts
Outdated
Show resolved
Hide resolved
35b315f
to
df7c1ed
Compare
df7c1ed
to
15992c9
Compare
f4d2fb7
to
5e26e5b
Compare
15992c9
to
59cc6db
Compare
59cc6db
to
86baae9
Compare
06990c0
to
f9b0419
Compare
6d487de
to
a61fbb6
Compare
f9b0419
to
73b5e55
Compare
ce9a665
to
a7a07eb
Compare
a61fbb6
to
10a4437
Compare
a7a07eb
to
fe3d272
Compare
size-limit report 📦
|
Can these listener be disposed 🤔? |
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.
LGTM
Merge activity
|
### **Introducing Views for Canvas Elements** This PR introduces the concept of views for canvas elements. Each canvas element, including those local element added via `addLocalElement`, now has an associated view instance. Views handle logic related to the view layer, such as binding mouse events to elements. ```typescript const modelView = std.gfx.view.get(model); view.on('pointerenter', () => { console.log('mouse entered the element.'); }); ``` You don’t need to manually instantiate views for elements. They are automatically managed by the `ViewManager`. ### **Custom View Classes** By default, each element's view is an instance of the `GfxElementModelView` class. However, you can define custom view classes for specific element types ```typescript import { GfxElementModelView } from '@blocksuite/block-std/gfx'; export class ShapeView extends GfxElementModelView { // Required static property: the model type this view is associated with static override type = 'shape'; onCreated() { this.on('click', () => { enterShapeTextEditor(this.model); }); } } // surface-spec.ts export surfaceSpec = [ //... other extensions ShapeView ]; ``` ### **Supported Events** The following mouse events are currently supported by views: - `click` - `dblclick` - `pointerdown` - `pointerenter` - `pointerleave` - `pointermove` - `pointerup`
fe3d272
to
91118b8
Compare
Introducing Views for Canvas Elements
This PR introduces the concept of views for canvas elements. Each canvas element, including those local element added via
addLocalElement
, now has an associated view instance. Views handle logic related to the view layer, such as binding mouse events to elements.You don’t need to manually instantiate views for elements. They are automatically managed by the
ViewManager
.Custom View Classes
By default, each element's view is an instance of the
GfxElementModelView
class. However, you can define custom view classes for specific element typesSupported Events
The following mouse events are currently supported by views:
click
dblclick
pointerdown
pointerenter
pointerleave
pointermove
pointerup