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

refactor(edgeless): element tree manager #8239

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

L-Sun
Copy link
Contributor

@L-Sun L-Sun commented Sep 9, 2024

TL;DR

This PR introduces TreeManager to maintain the container-children relationship among GfxModels. This change can make sure an element only has zero or one container.

What changes:

  • A new TreeManager is introduced to maintain the container-children relationship. Its implementation references the relevant code previously used in group in surface-model.ts.
  • Removed code related to the container-children relationship watcher of group.
  • The ContainerElement interface and related code have been moved from element-model.ts to a new file, container-element.ts.
  • Simplified the implementation of the ContainerElement interface in GroupLikeModel and FrameModel.
  • Some type annotation changes: from BlockSuite.EdgelessModel to GfxModel.

About test:

The existing tests already cover the changes mentioned above, including the relationship changes after operations on the child elements of frames and groups.

Copy link

vercel bot commented Sep 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocksuite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 14, 2024 10:27am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
blocksuite-docs ⬜️ Ignored (Inspect) Visit Preview Oct 14, 2024 10:27am

Copy link

changeset-bot bot commented Sep 9, 2024

⚠️ No Changeset found

Latest commit: 1e7573e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

graphite-app bot commented Sep 9, 2024

Your org has enabled the Graphite merge queue for merging into master

Add 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.

Copy link
Contributor Author

L-Sun commented Sep 9, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @L-Sun and the rest of your teammates on Graphite Graphite

Copy link

nx-cloud bot commented Sep 9, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1e7573e. 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 target

Sent with 💌 from NxCloud.

@L-Sun L-Sun changed the title refactor(edgeless): move element tree utilities to std refactor(edgeless): element tree manager Sep 9, 2024
doouding pushed a commit that referenced this pull request Sep 12, 2024
Closes: [BS-1398](https://linear.app/affine-design/issue/BS-1398/[bug]-拖出-frame-后-mindmap-依然跟随-frame),  [BS-1400](https://linear.app/affine-design/issue/BS-1400/mindmap无法移出frame)

This PR fix mindmap is moved with frame moving when the mindmap has been drag out of frame.

### What changes
- add workround to avoid multiple container in `FrameManager` for nodes of mindmap.
  - The fix can be refactored after #8239
- add frame and mindmap e2e tests
@L-Sun L-Sun force-pushed the l-sun/refactor/element-tree branch from a21a0ac to 3db021b Compare October 8, 2024 01:40
@L-Sun L-Sun force-pushed the l-sun/refactor/element-tree branch from 3db021b to 8824b32 Compare October 8, 2024 09:48
Copy link
Contributor

github-actions bot commented Oct 8, 2024

size-limit report 📦

Path Size
@blocksuite/affine 13 B (0%)
@blocksuite/affine/effects 2.06 MB (-0.04% 🔽)
@blocksuite/affine/block-std 154.64 KB (+0.07% 🔺)
@blocksuite/affine/block-std/gfx 77.28 KB (+0.46% 🔺)
@blocksuite/affine/global 13 B (0%)
@blocksuite/affine/global/utils 13.82 KB (0%)
@blocksuite/affine/global/env 210 B (0%)
@blocksuite/affine/global/exceptions 552 B (0%)
@blocksuite/affine/global/di 1.65 KB (0%)
@blocksuite/affine/global/types 13 B (0%)
@blocksuite/affine/store 78.36 KB (0%)
@blocksuite/affine/inline 31.37 KB (0%)
@blocksuite/affine/inline/consts 51 B (0%)
@blocksuite/affine/inline/types 13 B (0%)
@blocksuite/affine/presets 1.86 MB (+0.02% 🔺)
@blocksuite/affine/blocks 1.94 MB (-0.02% 🔽)
@blocksuite/affine/blocks/schemas 87.54 KB (+0.34% 🔺)

Copy link
Collaborator

@Saul-Mirone Saul-Mirone left a comment

Choose a reason for hiding this comment

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

LGTM

@L-Sun L-Sun added the merge label Oct 14, 2024
Copy link
Contributor Author

L-Sun commented Oct 14, 2024

Merge activity

  • Oct 14, 5:18 AM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Oct 14, 6:24 AM EDT: A user added this pull request to the Graphite merge queue.
  • Oct 14, 6:30 AM EDT: A user merged this pull request with the Graphite merge queue.

### TL;DR
This PR introduces `TreeManager` to maintain the container-children relationship among `GfxModel`s. This change can make sure an element only has zero or one container.

### What changes:
- A new `TreeManager` is introduced to maintain the container-children relationship.  Its implementation references the relevant code previously used in group in `surface-model.ts`.
- Removed code related to the container-children relationship watcher of group.
- The `ContainerElement` interface and related code have been moved from `element-model.ts` to a new file, `container-element.ts`.
- Simplified the implementation of the `ContainerElement` interface in `GroupLikeModel` and `FrameModel`.
- Some type annotation changes: from `BlockSuite.EdgelessModel` to `GfxModel`.

### About test:
The existing tests already cover the changes mentioned above, including the relationship changes after operations on the child elements of frames and groups.
@L-Sun L-Sun force-pushed the l-sun/refactor/element-tree branch from 80a2b6d to 1e7573e Compare October 14, 2024 10:25
L-Sun added a commit that referenced this pull request Oct 14, 2024
This PR removes redundant code related to the container-child element relationship, which is now maintained by the new `TreeManager` after #8239 .
@graphite-app graphite-app bot merged commit 1e7573e into master Oct 14, 2024
36 checks passed
@graphite-app graphite-app bot deleted the l-sun/refactor/element-tree branch October 14, 2024 10:30
L-Sun added a commit that referenced this pull request Oct 14, 2024
This PR refactor group test utils with container interface after PR #8239
donteatfriedrice added a commit that referenced this pull request Oct 16, 2024
## Features:

[feat: markdown adapter with latex](#8503)

[feat: support notion block equation html import](#8504)

[feat: support edgeless tidy up](#8516)

[feat: support notion callout block to blocksuite quote block](#8523)

[feat(playground): add import notion zip entry](#8527)

## Bugfix:

[fix(blocks): auto focus latex block](#8505)

[fix: enhance button layout with icon alignment](#8508)

[fix(edgeless): ime will crash edgeless text width](#8506)

[fix(edgeless): edgeless text is deleted when first block is empty](#8512)

[fix: notion html quote block import](#8515)

[fix: yjs warning](#8519)

[fix(blocks): real nested list on html export](#8511)

[fix(edgeless): cmd a will select element inner frame](#8517)

[fix(edgeless): disable contenteditable when edgeless text not in editing state](#8525)

[fix: import notion toggle list as toggle bulleted list](#8528)

## Refactor:

[refactor(database): signals version datasource api](#8513)

[refactor(edgeless): element tree manager](#8239)

[refactor(blocks): simplify frame manager implementation](#8507)

[refactor: update group test utils using container interface](#8518)

[refactor: update frame test with container test uitls](#8520)

[refactor(database): context-menu ui and ux](#8467)

[refactor: move chat block to affine](#8420)

## Misc

[perf: optimize snapshot job handling](#8428)

[perf(edgeless): disable shape shadow blur](#8532)

[chore: bump up all non-major dependencies](#8514)

[chore: Lock file maintenance](#8510)

## Docs

[docs: fix table structure warning](#8509)

[docs: edgeless data structure desc](#8531)

[docs: update link](#8533)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants