- Add a FALSE_VALUES set containing various falsy string representations
- Support Chinese negation terms like "否", "不", "错", etc.
- Optimize the implementation of cellFromString method
Key Changes:
1. **Code Reorganization and Consolidation**
- Created new centralized extension management through new files:
- `enableEditorExtension` in `extensions/entry/enable-editor.ts`
- `enablePreviewExtension` in `extensions/entry/enable-preview.ts`
- Removed several spec-related files that are now consolidated:
- Removed `specs/edgeless.ts`
- Removed `specs/page.ts`
- Removed `specs/preview.ts`
2. **Template Management**
- Added new `register-templates.ts` file to handle template registration
- Moved template registration logic from `specs/edgeless.ts` to this new file
- Templates now include both edgeless and sticker templates
3. **Extension Management Changes**
- Simplified extension enabling process through new centralized functions
- `enableEditorExtension` now handles both page and edgeless modes
- `enablePreviewExtension` consolidates preview-related extensions
- Removed duplicate code for extension management
4. **Preview Functionality Updates**
- Streamlined preview spec management
- Consolidated footnote configuration
- Improved theme and preview extension handling
5. **Dependencies and Effects**
- Updated how effects are registered and managed
- Simplified initialization process in `index.ts`
- More organized approach to handling framework providers
The main theme of this PR appears to be code consolidation and simplification, moving from multiple specialized files to more centralized, reusable extension management. This should make the codebase more maintainable and reduce duplication while keeping the same functionality.
The changes primarily affect the editor's extension system, preview functionality, and template management, making these systems more modular and easier to maintain.
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.
Let me analyze this diff and provide a clear description of the changes.
This PR introduces several significant changes focused on AI integration and code organization in the AFFiNE codebase:
1. **Enhanced SpecBuilder Functionality** (`blocksuite/affine/shared/src/utils/spec/spec-builder.ts`):
- Added method chaining by returning `this` from `extend`, `omit`, and `replace` methods
- Added new utility methods:
- `hasAll(target: ExtensionType[])`: Checks if all specified extensions exist
- `hasOneOf(target: ExtensionType[])`: Checks if at least one specified extension exists
2. **AI Extensions Modularization**:
- Split the large AI-related code into separate modular files under `packages/frontend/core/src/blocksuite/ai/extensions/`:
- `ai-code.ts`: Code block AI integration
- `ai-edgeless-root.ts`: Edgeless mode AI features
- `ai-image.ts`: Image block AI capabilities
- `ai-page-root.ts`: Page root AI integration
- `ai-paragraph.ts`: Paragraph block AI features
- `enable-ai.ts`: Central AI extension enablement logic
3. **Widget Improvements**:
- Enhanced `AffineAIPanelWidget` and `EdgelessCopilotWidget` with proper widget extensions
- Moved widget-specific extensions into their respective files
- Added proper type definitions and component registrations
4. **Code Organization**:
- Simplified exports in `index.ts`
- Better separation of concerns between different AI-related components
- More modular approach to AI feature integration
5. **AI Integration Architecture**:
- Introduced a new `enableAIExtension` function that handles:
- Replacing standard blocks with AI-enhanced versions
- Conditional enabling of AI features based on the current spec configuration
- Extension of AI chat capabilities
The changes primarily focus on improving code organization, maintainability, and the architecture of AI feature integration in the AFFiNE editor. The modularization will make it easier to maintain and extend AI capabilities across different block types and editor modes.
### TL;DR
Relocated AI-related code from `presets` directory to a dedicated `ai` directory for better organization and maintainability.
### What changed?
- Moved AI-related code from `blocksuite/presets/ai` to `blocksuite/ai`
- Relocated AI chat block code from `blocksuite/blocks` to `blocksuite/ai/blocks`
- Updated imports across files to reflect new directory structure
- Renamed `registerBlocksuitePresetsCustomComponents` to `registerAIEffects`
- Fixed path references in GitHub workflow file
### How to test?
1. Build and run the application
2. Verify AI functionality works as expected:
- Test AI chat blocks
- Check AI panel functionality
- Verify AI copilot features
- Ensure AI-related UI components render correctly
### Why make this change?
This restructuring improves code organization by:
- Giving AI features a dedicated directory that better reflects their importance
- Making the codebase more maintainable by grouping related AI functionality
- Reducing confusion by removing AI code from the more general `presets` directory
- Creating clearer boundaries between AI and non-AI related code
refactor(editor): invalidate support in turbo renderer
- Added `invalidate()` method to clear cache and canvas
- Simplified debug pane controls to single invalidate button
- Replaced layout update with refresh debounce on block updates
- Improved cache handling and bitmap drawing flow
refactor: refresh after invalidate
### TL;DR
Relocated AI item components from BlockSuite to the frontend codebase and updated related imports.
### What changed?
- Moved AI item components from `blocksuite/affine/components/src/ai-item` to `packages/frontend/core/src/blocksuite/presets/ai/_common/components/ai-item`
- Updated all imports referencing the old AI item component location to point to the new location
- Removed AI item exports from BlockSuite's package.json and effects registration
- Added AI item effects registration to frontend presets
### How to test?
1. Verify AI functionality works as expected in:
- Chat panels
- AI toolbars
- Edgeless copilot
- Slash menu
2. Confirm no AI-related console errors appear
3. Test error handling scenarios (unauthorized, payment required, network errors)
### Why make this change?
This change consolidates AI-related components into the frontend codebase where they are primarily used, rather than keeping them in BlockSuite. This improves code organization by placing components closer to their implementation and usage, while reducing unnecessary coupling between packages.
### TL;DR
Moved AI-related components from BlockSuite core to the frontend presets directory to better organize AI functionality.
### What changed?
- Relocated AI panel, copilot tool, and related components from BlockSuite core to frontend presets
- Moved AI widget definitions and registrations to the presets directory
- Updated imports to reference new component locations
- Removed AI component registrations from core effects.ts
- Added AI component registrations to presets effects.ts
### How to test?
1. Verify AI panel functionality works as expected in the editor
2. Test copilot tool interactions in edgeless mode
3. Confirm AI suggestions and responses still appear correctly
4. Check that AI toolbar buttons and menus function properly
5. Ensure AI error states and loading indicators display correctly
### Why make this change?
This restructuring improves code organization by moving AI-specific functionality out of the core BlockSuite library and into the frontend presets where it more logically belongs. This separation of concerns makes the codebase more maintainable and allows for better modularity of AI features.
### TL;DR
Reorganized component registration in the effects module by grouping related components into separate functions.
### What changed?
- Split the monolithic component registration into logical categories:
- Root components (page, preview, edgeless)
- Widgets (panels, toolbars, modals)
- Edgeless toolbar components (tools, menus, buttons)
- Edgeless panel components (alignment, color, style)
- Edgeless editor components (text editors, label editors)
- AI components (panels, placeholders)
- Misc components (modals, loading, previews)
- Added descriptive comments for each component group
- Maintained all existing component registrations while improving code organization
### How to test?
1. Launch the application
2. Verify all components render correctly:
- Check page/preview/edgeless views
- Test toolbar functionality
- Verify panels and modals work
- Ensure AI features function properly
- Validate edgeless editor capabilities
### Why make this change?
Improves code maintainability and readability by:
- Grouping related components together
- Making it easier to find and modify specific component registrations
- Providing better structure for future component additions
- Reducing cognitive load when working with component registrations
### TL;DR
Refactored `SpecProvider` singleton access pattern and reorganized adapter/extension code structure.
### What changed?
- Changed `SpecProvider.getInstance()` to `SpecProvider._` for cleaner singleton access
- Moved adapter/extension code from `_common` directory to dedicated `adapters` and `extensions` folders
- Consolidated adapter extensions into a single file
- Removed unused dependencies from package.json
- Deleted unnecessary schema files
- Extracted `MobileSpecsPatches` class into the mobile patching code
- Updated all references to use the new `SpecProvider._` accessor
### How to test?
- Verify all specs are properly registered and accessible via `SpecProvider._`
- Test adapter functionality for HTML, Markdown, Notion HTML and plain text
- Check mobile-specific features and patches work correctly
- Ensure preview functionality works in both page and edgeless modes
### Why make this change?
- Improves code organization by properly separating adapters and extensions
- Simplifies singleton access pattern
- Removes unnecessary dependencies and files
- Makes the codebase more maintainable by consolidating related functionality
Close [BS-2647](https://linear.app/affine-design/issue/BS-2647/ios返回手势会误触发focus导致弹起键盘)
### What Changes:
- Using `click` event instead of `pointerDown` event to handle selection logic in page block, because gestures on mobile devices can trigger the `pointerDown` event, causing the cursor to update and unexpectedly bring up the virtual keyboard.
Fix issue [AF-2252](https://linear.app/affine-design/issue/AF-2252).
## What Changed?
- Remove useless `generateAnswer` configuration for inline ask ai
- Refactor the common `updateAIPanelConfig` function
- Use empty string instead of meaningless `placeholder` string
- Remove unnecessary high-order function wrappers
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.