Skip to content
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 dnd #9988

Open
wants to merge 5 commits into
base: canary
Choose a base branch
from
Open

feat: edgeless dnd #9988

wants to merge 5 commits into from

Conversation

doouding
Copy link
Member

@doouding doouding commented Feb 6, 2025

Changed

  • Support edgelss dnd
  • Simplify the drag-handle state

Copy link
Member Author

doouding commented Feb 6, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 44.52926% with 218 lines in your changes missing coverage. Please review.

Project coverage is 53.87%. Comparing base (ba52abe) to head (76c9a7e).
Report is 2 commits behind head on canary.

Files with missing lines Patch % Lines
...get-drag-handle/src/watchers/drag-event-watcher.ts 39.66% 178 Missing ⚠️
...widget-drag-handle/src/middleware/blocks-filter.ts 15.00% 17 Missing ⚠️
...idget-drag-handle/src/watchers/edgeless-watcher.ts 69.23% 7 Missing and 1 partial ⚠️
...t-drag-handle/src/watchers/handle-event-watcher.ts 0.00% 5 Missing ⚠️
...-drag-handle/src/watchers/pointer-event-watcher.ts 50.00% 2 Missing and 1 partial ⚠️
...te/affine/block-surface/src/surface-transformer.ts 0.00% 1 Missing and 1 partial ⚠️
...ite/framework/store/src/transformer/transformer.ts 66.66% 1 Missing and 1 partial ⚠️
...fine/widget-drag-handle/src/helpers/rect-helper.ts 0.00% 1 Missing ⚠️
blocksuite/affine/widget-drag-handle/src/utils.ts 0.00% 1 Missing ⚠️
...k/block-std/src/gfx/model/surface/surface-model.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary    #9988      +/-   ##
==========================================
- Coverage   53.90%   53.87%   -0.03%     
==========================================
  Files        2293     2294       +1     
  Lines      105467   105693     +226     
  Branches    17463    17538      +75     
==========================================
+ Hits        56851    56947      +96     
- Misses      47245    47374     +129     
- Partials     1371     1372       +1     
Flag Coverage Δ
server-test 78.17% <ø> (-0.06%) ⬇️
unittest 31.69% <18.06%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@doouding doouding force-pushed the 02-05-feat_edgeless_dnd branch 3 times, most recently from 9fa84e1 to a0aee4d Compare February 11, 2025 10:31
@doouding doouding marked this pull request as ready for review February 11, 2025 11:12
@doouding doouding requested a review from a team as a code owner February 11, 2025 11:12
@graphite-app graphite-app bot requested review from a team February 11, 2025 11:12
@doouding doouding requested review from Saul-Mirone and removed request for a team February 11, 2025 11:13
@@ -35,6 +36,8 @@ export type BeforeExportPayload =
| {
model: DraftModel;
type: 'block';
action: 'default' | 'skip';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the meaning of this new action and transformer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to skip some models during export to snapshot without modifying the draf model.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, but why you don't want to modify the draft model? I think model.children.filter is more straight forward than adding flags.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. I thought the DraftModel is just an other name of BlockModel. So we can modify the draft model without affecting the original BlockModel ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like toDraftModel has not been called.

}

if (payload.model.flavour === 'affine:surface') {
(payload.transformer as SurfaceBlockTransformer).selectedElements =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wired and not really type safe, maybe rename adapterConfigs to transformerConfigs and use it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to attach or send some message to the specific block transformer to change its behaviour. Any way to do that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about modifying BaseBlockTransformer constructor to accept adapterConfigs, so that we can pass information for Transformer to specific block transformer?

matchFlavours(parent, [SurfaceBlockModel]) &&
!selectedIds.has(payload.model.id)
) {
payload.action = 'skip';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we add action for one type of payload, we need to add this for all the transformer payloads. But if you're trying to not transform some node, why not just filter the children in parent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any example of the way you mentioned ? I see the _blockToSnapshot method will directly access the model.children, how to filter out the children I don't want to transform?

@doouding doouding force-pushed the 02-05-feat_edgeless_dnd branch from a3e978c to a9aeb10 Compare February 11, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants