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(editor): modular custom specs #10398

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

Saul-Mirone
Copy link
Contributor

@Saul-Mirone Saul-Mirone commented Feb 24, 2025

Key Changes:

  1. Removal of Scroll Anchoring Widget
  • Removed the scroll anchoring widget import and its related implementation from blocksuite/affine/block-root/src/common-specs/widgets.ts
  1. Enhanced React-Lit Integration
  • Added ReactWebComponent type export in packages/frontend/component/src/lit-react/index.ts
  • Refactored text renderer component to use React integration:
    • Added React import and created LitTextRenderer component using createReactComponentFromLit
    • Moved the component declaration to a more appropriate location
  1. AI Feature Flag Integration
  • Added feature flag check for AI functionality in enableAIExtension
  • Only enables AI extensions if the enable_ai flag is true
  1. Component Restructuring
  • Moved several components and utilities to dedicated extension files
  • Consolidated Lit adapter implementations
  • Removed direct widget imports in favor of extension-based approach
  • Reorganized editor component structure for better maintainability
  1. File Reorganization
  • Removed specs/custom/spec-patchers.ts and distributed its functionality across multiple extension files
  • Created new extension files for various features like:
    • Attachment embed views
    • Doc mode service
    • Doc URL handling
    • Edgeless clipboard
    • Mobile support
    • Note configuration
    • Various service patches (notification, peek view, quick search, etc.)
  1. Mobile Support Improvements
  • Refactored mobile extension enablement to be more modular
  • Moved mobile-specific widget omissions into a dedicated extension
  1. Type System Improvements
  • Added more specific type imports for editors and components
  • Enhanced type safety across the codebase

This PR appears to be a significant refactoring effort focused on:

  1. Improving code organization through better separation of concerns
  2. Enhancing the integration between React and Lit components
  3. Adding feature flag support for AI capabilities
  4. Making the codebase more maintainable and modular
  5. Improving mobile support
  6. Strengthening type safety

The changes suggest a move towards a more extension-based architecture, where functionality is more clearly separated into distinct modules rather than being centralized in larger files.

Copy link
Contributor Author


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.

@Saul-Mirone Saul-Mirone marked this pull request as ready for review February 24, 2025 08:04
@Saul-Mirone Saul-Mirone requested a review from a team as a code owner February 24, 2025 08:04
@graphite-app graphite-app bot requested review from a team February 24, 2025 08:06
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 54.23%. Comparing base (1b2a437) to head (60b994f).
Report is 1 commits behind head on canary.

Files with missing lines Patch % Lines
...end/core/src/blocksuite/ai/extensions/enable-ai.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #10398      +/-   ##
==========================================
- Coverage   54.23%   54.23%   -0.01%     
==========================================
  Files        2336     2340       +4     
  Lines      108117   108150      +33     
  Branches    17876    17887      +11     
==========================================
+ Hits        58639    58652      +13     
- Misses      48140    48169      +29     
+ Partials     1338     1329       -9     
Flag Coverage Δ
server-test 78.96% <ø> (+0.01%) ⬆️
unittest 31.19% <20.00%> (-0.01%) ⬇️

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.

Copy link

graphite-app bot commented Feb 24, 2025

Merge activity

Key Changes:

1. **Removal of Scroll Anchoring Widget**
- Removed the scroll anchoring widget import and its related implementation from `blocksuite/affine/block-root/src/common-specs/widgets.ts`

2. **Enhanced React-Lit Integration**
- Added `ReactWebComponent` type export in `packages/frontend/component/src/lit-react/index.ts`
- Refactored text renderer component to use React integration:
  - Added React import and created `LitTextRenderer` component using `createReactComponentFromLit`
  - Moved the component declaration to a more appropriate location

3. **AI Feature Flag Integration**
- Added feature flag check for AI functionality in `enableAIExtension`
- Only enables AI extensions if the `enable_ai` flag is true

4. **Component Restructuring**
- Moved several components and utilities to dedicated extension files
- Consolidated Lit adapter implementations
- Removed direct widget imports in favor of extension-based approach
- Reorganized editor component structure for better maintainability

5. **File Reorganization**
- Removed `specs/custom/spec-patchers.ts` and distributed its functionality across multiple extension files
- Created new extension files for various features like:
  - Attachment embed views
  - Doc mode service
  - Doc URL handling
  - Edgeless clipboard
  - Mobile support
  - Note configuration
  - Various service patches (notification, peek view, quick search, etc.)

6. **Mobile Support Improvements**
- Refactored mobile extension enablement to be more modular
- Moved mobile-specific widget omissions into a dedicated extension

7. **Type System Improvements**
- Added more specific type imports for editors and components
- Enhanced type safety across the codebase

This PR appears to be a significant refactoring effort focused on:
1. Improving code organization through better separation of concerns
2. Enhancing the integration between React and Lit components
3. Adding feature flag support for AI capabilities
4. Making the codebase more maintainable and modular
5. Improving mobile support
6. Strengthening type safety

The changes suggest a move towards a more extension-based architecture, where functionality is more clearly separated into distinct modules rather than being centralized in larger files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants